001: /*
002: * Copyright (C) 2005 Jeff Tassin
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package com.jeta.swingbuilder.gui.effects;
020:
021: import java.awt.BorderLayout;
022: import java.awt.event.ActionEvent;
023: import java.awt.event.ActionListener;
024:
025: import com.jeta.forms.gui.effects.SolidPainter;
026: import com.jeta.forms.gui.form.GridView;
027: import com.jeta.forms.store.properties.effects.PaintProperty;
028: import com.jeta.forms.store.properties.effects.SolidProperty;
029: import com.jeta.open.gui.framework.JETAController;
030: import com.jeta.open.gui.framework.JETAPanel;
031: import com.jeta.swingbuilder.gui.components.panel.SwingBuilderPanel;
032:
033: /**
034: * @author Jeff Tassin
035: */
036: public class SolidView extends JETAPanel implements PaintView {
037: /**
038: * The fillProperties form.
039: */
040: private SwingBuilderPanel m_view;
041:
042: /**
043: * The preview for the gradient settings
044: */
045: private GridView m_preview;
046:
047: /**
048: * The property
049: */
050: private SolidProperty m_prop = new SolidProperty();
051: private SolidPainter m_painter = new SolidPainter();
052:
053: /**
054: * ctor
055: */
056: public SolidView(GridView preview) {
057: m_preview = preview;
058: setLayout(new BorderLayout());
059: m_view = new SwingBuilderPanel(
060: "com/jeta/swingbuilder/gui/effects/solidProperties.frm");
061: add(m_view, BorderLayout.CENTER);
062: setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10,
063: 10, 10));
064: setController(new SolidViewController());
065: updatePreview();
066: }
067:
068: /**
069: * @return the property for this view
070: */
071: public PaintProperty getPaintProperty() {
072: return new PaintProperty(getSolidProperty());
073: }
074:
075: public SolidProperty getSolidProperty() {
076: m_prop.setColorProperty(m_view
077: .getColorProperty(SolidViewNames.ID_COLOR_SELECTOR));
078: return m_prop;
079: }
080:
081: /**
082: * Sets the property for the view
083: */
084: public void setPaintProperty(PaintProperty pp) {
085: if (pp.getPaintDelegate() instanceof SolidProperty) {
086: SolidProperty sp = (SolidProperty) pp.getPaintDelegate();
087: m_prop.setValue(sp);
088: m_view.setColorProperty(SolidViewNames.ID_COLOR_SELECTOR,
089: sp.getColorProperty());
090: updatePreview();
091: }
092: }
093:
094: public void updatePreview() {
095: m_painter.setSolidProperty(getSolidProperty());
096: m_preview.setBackgroundPainter(m_painter);
097: }
098:
099: /**
100: * The controller for the SolidView class
101: */
102: public class SolidViewController extends JETAController {
103: public SolidViewController() {
104: super (SolidView.this );
105: assignAction(SolidViewNames.ID_COLOR_SELECTOR,
106: new ColorChangedAction());
107: }
108:
109: public class ColorChangedAction implements ActionListener {
110: public void actionPerformed(ActionEvent evt) {
111: updatePreview();
112: }
113: }
114: }
115:
116: }
|