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.components.line;
020:
021: import java.awt.BorderLayout;
022: import java.awt.Color;
023:
024: import javax.swing.JSpinner;
025: import javax.swing.SpinnerNumberModel;
026:
027: import com.jeta.forms.store.properties.LineProperty;
028: import com.jeta.open.gui.framework.JETAPanel;
029: import com.jeta.swingbuilder.gui.components.panel.SwingBuilderPanel;
030:
031: /**
032: * View that is used to create and edit a single line
033: *
034: * @author Jeff Tassin
035: */
036: public class LinePropertiesView extends JETAPanel {
037: /**
038: * The actual view
039: */
040: private SwingBuilderPanel m_view;
041:
042: /**
043: * The current line property
044: */
045: private LineProperty m_prop = new LineProperty();
046:
047: /**
048: * ctor
049: */
050: public LinePropertiesView() {
051: this (null);
052: }
053:
054: /**
055: * ctor
056: */
057: public LinePropertiesView(LineProperty lp) {
058: if (lp != null)
059: m_prop.setValue(lp);
060:
061: Color new_color = m_prop.getColor();
062:
063: setLayout(new BorderLayout());
064: m_view = new SwingBuilderPanel(
065: "com/jeta/swingbuilder/gui/components/line/lineProperties.frm");
066: add(m_view, BorderLayout.CENTER);
067: setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10,
068: 10, 10));
069:
070: JSpinner sp = m_view
071: .getSpinner(LinePropertiesNames.ID_LINE_THICKNESS_FIELD);
072: sp.setModel(new SpinnerNumberModel(1, 1, 100, 1));
073: sp.setValue(new Integer(m_prop.getThickness()));
074:
075: m_view.setColorProperty(LinePropertiesNames.ID_COLOR_SELECTOR,
076: m_prop.getColorProperty());
077: setController(new LinePropertiesController(this ));
078: }
079:
080: public int getThickness() {
081: JSpinner sp = m_view
082: .getSpinner(LinePropertiesNames.ID_LINE_THICKNESS_FIELD);
083: Integer ival = (Integer) sp.getValue();
084: return ival.intValue();
085: }
086:
087: /**
088: * Sets the current line thickness
089: */
090: public void setThickness(int thk) {
091: m_prop.setThickness(thk);
092: }
093:
094: public LineProperty getLineProperty() {
095: m_prop
096: .setColorProperty(m_view
097: .getColorProperty(LinePropertiesNames.ID_COLOR_SELECTOR));
098: m_prop.setThickness(getThickness());
099: return m_prop;
100: }
101:
102: /**
103: * Updates the line component in the preview pane with the latest properties
104: */
105: public void updatePreview() {
106:
107: }
108:
109: }
|