Revision 8280

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/CharacterMarker.java
40 40
 */
41 41

  
42 42
/* CVS MESSAGES:
43
*
44
* $Id$
45
* $Log$
46
* Revision 1.1  2006-10-18 07:54:06  jaume
47
* *** empty log message ***
48
*
49
*
50
*/
43
 *
44
 * $Id$
45
 * $Log$
46
 * Revision 1.2  2006-10-24 08:02:51  jaume
47
 * *** empty log message ***
48
 *
49
 * Revision 1.1  2006/10/18 07:54:06  jaume
50
 * *** empty log message ***
51
 *
52
 *
53
 */
51 54
package com.iver.cit.gvsig.fmap.core.symbols;
52 55

  
53 56
import java.awt.Color;
57
import java.awt.Dimension;
54 58
import java.awt.Font;
55 59
import java.awt.Graphics2D;
56 60
import java.awt.Rectangle;
......
58 62
import java.awt.geom.AffineTransform;
59 63
import java.awt.geom.Point2D;
60 64

  
65
import javax.swing.SwingUtilities;
66

  
61 67
import org.apache.batik.ext.awt.geom.PathLength;
62 68

  
63 69
import com.iver.cit.gvsig.fmap.core.FPoint2D;
64 70
import com.iver.cit.gvsig.fmap.core.FShape;
65 71
import com.iver.cit.gvsig.fmap.core.IGeometry;
66 72
import com.iver.cit.gvsig.fmap.core.ISymbol;
73
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
67 74
import com.iver.cit.gvsig.fmap.core.v02.FConverter;
75
import com.iver.utiles.StringUtilities;
68 76
import com.iver.utiles.XMLEntity;
69 77
import com.vividsolutions.jts.geom.Geometry;
70 78
import com.vividsolutions.jts.geom.Point;
71 79

  
72 80
public class CharacterMarker extends AbstractMarker {
73 81

  
74
    private Font font;
75
    private Color color = Color.BLACK;
76
    private int symbol;
82
	private Font font;
77 83

  
78
    /**
79
     * Creates a new instance of CharacterMarker with default values
80
     *
81
     */
82
    public CharacterMarker() {
83
    	super();
84
    }
84
	private Color color = Color.BLACK;
85 85

  
86
    /**
87
     * Creates a new instance of CharacterMarker specifying the marker source font,
88
     * the character code corresponding to the symbol, and the color that will be
89
     * used in rendering time.
90
     *
91
     * @param font - src Font
92
     * @param charCode - character code of the symbol for this font
93
     * @param color - color to be used in when rendering.
94
     */
95
    public CharacterMarker(Font font, int charCode, Color color) {
96
    	super();
97
    	this.font = font;
98
    	symbol = charCode;
99
    	this.color = color;
100
    }
86
	private int symbol;
101 87

  
102
    public Font getFont() {
103
        if (font == null) {
104
            font = new Font("Arial", Font.PLAIN, 20);
105
        }
106
        return font;
107
    }
88
	/**
89
	 * Creates a new instance of CharacterMarker with default values
90
	 *
91
	 */
92
	public CharacterMarker() {
93
		super();
94
	}
108 95

  
109
    public void setFont(Font font) {
110
        this.font = font;
111
    }
96
	/**
97
	 * Creates a new instance of CharacterMarker specifying the marker source
98
	 * font, the character code corresponding to the symbol, and the color that
99
	 * will be used in rendering time.
100
	 *
101
	 * @param font -
102
	 *            src Font
103
	 * @param charCode -
104
	 *            character code of the symbol for this font
105
	 * @param color -
106
	 *            color to be used in when rendering.
107
	 */
108
	public CharacterMarker(Font font, int charCode, Color color) {
109
		super();
110
		this.font = font;
111
		symbol = charCode;
112
		this.color = color;
113
	}
112 114

  
113
    public ISymbol getSymbolForSelection() {
114
        // TODO Auto-generated method stub
115
        return null;
116
    }
115
	public Font getFont() {
116
		if (font == null) {
117
			font = new Font("Arial", Font.PLAIN, 20);
118
		}
119
		return font;
120
	}
117 121

  
118
    public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) {
119
        g.setFont(getFont());
120
        g.setColor(color);
121
        g.rotate(getRotation());
122
        Point2D p = null;
123
        switch (shp.getShapeType()) {
124
        case FShape.POINT:
125
            p = new Point2D.Double(((FPoint2D) shp).getX(),
126
                    ((FPoint2D) shp).getY());
127
//            p = affineTransform.transform(p, null);
128
            break;
129
        case FShape.LINE:
130
            PathLength pathLen = new PathLength(shp);
131
            float midDistance = pathLen.lengthOfPath() / 2;
132
            p = pathLen.pointAtLength(midDistance);
133
//            p = affineTransform.transform(p, null);
134
            break;
135
        case FShape.POLYGON:
136
            Geometry geom = FConverter.java2d_to_jts(shp);
137
            Point centroid = geom.getCentroid();
138
            p = new Point2D.Double(centroid.getX(), centroid.getY());
139
        }
122
	public void setFont(Font font) {
123
		this.font = font;
124
	}
140 125

  
141
        char[] text = new char[] {(char) symbol };
142
        g.drawChars(text, 0, text.length, (int) p.getX(), (int)p.getY());
143
    }
126
	public ISymbol getSymbolForSelection() {
127
		// TODO Auto-generated method stub
128
		return null;
129
	}
144 130

  
145
    public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, Shape shp) {
146
        // TODO Auto-generated method stub
147
        return 0;
148
    }
131
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) {
132
		g.setFont(getFont());
133
		g.setColor(color);
134
		g.rotate(getRotation());
135
		Point2D p = null;
136
		switch (shp.getShapeType()) {
137
		case FShape.POINT:
138
			p = new Point2D.Double(((FPoint2D) shp).getX(), ((FPoint2D) shp)
139
					.getY());
140
			// p = affineTransform.transform(p, null);
141
			break;
142
		case FShape.LINE:
143
			PathLength pathLen = new PathLength(shp);
144
			float midDistance = pathLen.lengthOfPath() / 2;
145
			p = pathLen.pointAtLength(midDistance);
146
			// p = affineTransform.transform(p, null);
147
			break;
148
		case FShape.POLYGON:
149
			Geometry geom = FConverter.java2d_to_jts(shp);
150
			Point centroid = geom.getCentroid();
151
			p = new Point2D.Double(centroid.getX(), centroid.getY());
152
		}
149 153

  
150
    public int getOnePointRgb() {
151
        return color.getRGB();
152
    }
154
		char[] text = new char[] { (char) symbol };
155
		g.drawChars(text, 0, text.length, (int) p.getX(), (int) p.getY());
156
	}
153 157

  
154
    public XMLEntity getXMLEntity() {
155
        // TODO Auto-generated method stub
156
        return null;
157
    }
158
	public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform,
159
			Shape shp) {
160
		// TODO Auto-generated method stub
161
		return 0;
162
	}
158 163

  
159
    public int getSymbolType() {
160
        return CHARACTER_MARKER;
161
    }
164
	public int getOnePointRgb() {
165
		return color.getRGB();
166
	}
162 167

  
163
    public boolean isSuitableFor(IGeometry geom) {
164
        // TODO Auto-generated method stub
165
        return false;
166
    }
168
	public XMLEntity getXMLEntity() {
169
		XMLEntity xml = new XMLEntity();
167 170

  
168
    public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r) {
169
//		Double p;
170
//		scaleInstance.transform(p = new Point2D.Double(r.getMinX(), r.getMinY()),p);
171
//		Font myFont = getFont();
172
//		int currFontSize = myFont.getSize();
173
//		double width = r.getWidth();
174
//		myFont.
171
		// color
172
		xml.putProperty("color", StringUtilities.color2String(color));
175 173

  
176
        g.setFont(font.deriveFont(scaleInstance));
174
		// font
175
		xml.putProperty("font", font.getFontName());
177 176

  
178
    }
177
		// font style
178
		xml.putProperty("fontStyle", font.getStyle());
179 179

  
180
    public void setCharacter(int symbol) {
181
        this.symbol = symbol;
182
    }
180
		// symbol code
181
		xml.putProperty("symbolCode", symbol);
182
		return xml;
183
	}
183 184

  
185
	public int getSymbolType() {
186
		return CHARACTER_MARKER;
187
	}
184 188

  
189
	public boolean isSuitableFor(IGeometry geom) {
190
		// TODO Auto-generated method stub
191
		return false;
192
	}
193

  
194
	public void drawInsideRectangle(Graphics2D g,
195
			AffineTransform scaleInstance, Rectangle r) {
196
		g.rotate(getRotation());
197
		// Sirve de algo el scaleInstance???
198
		// g.setFont(font.deriveFont(scaleInstance));
199
		double h = r.getHeight();
200
		g.setFont(font.deriveFont(
201
				(float) (h * FConstant.FONT_HEIGHT_SCALE_FACTOR)).deriveFont(
202
				scaleInstance));
203
		r.y = (int) h;
204
		char[] text = new char[] { (char) symbol };
205
		g.drawChars(text, 0, text.length, (int) r.getX(), (int) r.getY());
206
	}
207

  
208
	public void setCharacter(int symbol) {
209
		this.symbol = symbol;
210
	}
185 211
}
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/RouteControPanel.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.3  2006-10-23 16:00:20  jaume
46
* Revision 1.4  2006-10-24 08:04:41  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.3  2006/10/23 16:00:20  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.2  2006/10/23 08:05:39  jaume
50 53
* GUI
51 54
*
......
102 105
    private JButton btnLoadStage = null;
103 106
    private JButton btnSaveStage = null;
104 107
    private ArrayList routeFlags;
105
    private ArrayList costs;
106
	private JLabel lblCost;
108
    private JLabel lblCost;
107 109
	private JLabel lblFlagAmout;
108 110
	private JButton btnPullDownStage;
109 111
	private JButton btnPushUpStage;
110 112
	private JButton btnRemoveStage;
111 113
	private JPanel southPanel;
112
	final String[] colName = new String[] {
113

  
114
	private final String[] colName = new String[] {
114 115
            PluginServices.getText(this, "enable"),
115 116
            PluginServices.getText(this, "stage"),
116 117
            PluginServices.getText(this, "cost"),
......
498 499
				_getFlags().set(selected[i], aux);
499 500
				selected[i]--;
500 501
				tblStages.addRowSelectionInterval(selected[i], selected[i]);
501

  
502 502
			}
503
			// move selection
504
			for (int i = 1; i < selected.length; i++) {
505
			}
503

  
506 504
		} else if (name.equals(getBtnPullDownStage().getName())) {
507 505
			// pull down
508 506
			int[] selected = tblStages.getSelectedRows();
......
517 515
				_getFlags().set(selected[i], aux);
518 516
				selected[i]++;
519 517
				tblStages.addRowSelectionInterval(selected[i], selected[i]);
520

  
521 518
			}
522 519

  
523
			// move selection
524
			for (int i = 1; i < selected.length; i++) {
525
			}
520

  
526 521
		} else if (name.equals(getBtnRemoveStage().getName())) {
527 522
			// remove
528 523
			int[] selected = tblStages.getSelectedRows();
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetPage1.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1  2006-10-19 15:12:10  jaume
46
* Revision 1.2  2006-10-24 08:04:41  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.1  2006/10/19 15:12:10  jaume
50
* *** empty log message ***
49 51
*
52
*
50 53
*/
51 54
package com.iver.cit.gvsig.graph.gui.wizard;
52 55

  
......
55 58
import java.awt.event.ActionListener;
56 59
import java.util.Hashtable;
57 60

  
61
import javax.swing.JCheckBox;
58 62
import javax.swing.JComboBox;
59 63
import javax.swing.JLabel;
60 64
import javax.swing.JPanel;
......
82 86
	private Object useLineLengthItem = "< "+PluginServices.getText(this, "use_line_length")+" >";
83 87

  
84 88
	private Object nullValue = "- "+PluginServices.getText(this, "none")+" -";
89
	private JCheckBox chkTypeField;
90
	private JCheckBox chkLengthField;
91
	private JCheckBox chkCostUnits;
92
	private JCheckBox chkSenseField;
93
	private JCheckBox chkCostField;
85 94

  
86 95
	NetPage1(NetWizard wizard) {
87 96
		super(wizard.getWizardComponents());
......
104 113
		for (int i = 0; i < ss.length; i++) {
105 114
			cmbTypeField.addItem(ss[i]);
106 115
		}
107
		contentPane.addComponent(PluginServices.getText(this, "selet_type_field")+":", cmbTypeField);
116
		chkTypeField = new JCheckBox(PluginServices.getText(this, "select_type_field")+":");
117
		chkTypeField.addActionListener(this);
118
		contentPane.addComponent(chkTypeField, cmbTypeField);
108 119

  
109 120
		// Length
110 121
		cmbLengthField = new JComboBox();
......
114 125
		for (int i = 0; i < ss.length; i++) {
115 126
			cmbLengthField.addItem(ss[i]);
116 127
		}
117
		contentPane.addComponent(PluginServices.getText(this, "selet_length_field")+":", cmbLengthField);
128
		chkLengthField = new JCheckBox(PluginServices.getText(this, "select_length_field")+":");
129
		chkLengthField.addActionListener(this);
130
		contentPane.addComponent(chkLengthField, cmbLengthField);
118 131

  
119 132
		// Cost
120
		contentPane.addComponent(
121
				PluginServices.getText(this, "cost_field"),
122
				cmbCostField = new JComboBox());
133
		chkCostField = new JCheckBox(PluginServices.getText(this, "cost_field")+":");
134
		chkCostField.addActionListener(this);
135
		contentPane.addComponent(chkCostField, cmbCostField = new JComboBox());
123 136

  
124 137
		cmbCostField.addItem(useLineLengthItem );
125 138
		cmbCostField.setToolTipText(PluginServices.getText(this, "cost_field_text"));
......
131 144

  
132 145
		// Costs units
133 146
		cmbCostUnits = new JComboBox(NetWizard.COST_UNITS);
134
		contentPane.addComponent(
135
				PluginServices.getText(this, "cost_units"), cmbCostUnits);
147
		chkCostUnits = new JCheckBox(PluginServices.getText(this, "cost_units")+":");
148
		chkCostUnits.addActionListener(this);
149
		contentPane.addComponent(chkCostUnits, cmbCostUnits);
136 150
		cmbCostUnits.setToolTipText(PluginServices.getText(this, "cost_units_text"));
137 151

  
138 152
		// Sense
......
144 158
		}
145 159
		cmbSenseField.addActionListener(this);
146 160
		cmbSenseField.setToolTipText(PluginServices.getText(this, "sense_field_text"));
147
		contentPane.addComponent(PluginServices.getText(this, "select_sense_field"),cmbSenseField);
161
		chkSenseField = new JCheckBox(PluginServices.getText(this, "select_sense_field")+":");
162
		chkSenseField.addActionListener(this);
163
		contentPane.addComponent(chkSenseField, cmbSenseField);
148 164
		actionPerformed(null);
149 165
		this.add(contentPane);
150 166
	}
......
153 169

  
154 170
		cmbCostUnits.setEnabled(
155 171
				!cmbCostField.getSelectedItem().equals(useLineLengthItem));
172
		if (chkTypeField.isSelected()) {
173
			owner.setTypeField(cmbTypeField.getSelectedItem().equals(nullValue)?
174
					null : (String) cmbTypeField.getSelectedItem());
175
			cmbTypeField.setEnabled(true);
176
		} else {
177
			owner.setTypeField(null);
178
			cmbTypeField.setEnabled(false);
179
		}
156 180

  
157
		owner.setFieldType(cmbTypeField.getSelectedItem().equals(nullValue)?
158
				null : (String) cmbTypeField.getSelectedItem());
159
		owner.setFieldLength(cmbLengthField.getSelectedItem().equals(nullValue)?
181
		if (chkLengthField.isSelected()) {
182
			owner.setLengthField(cmbLengthField.getSelectedItem().equals(nullValue)?
160 183
				null : (String) cmbLengthField.getSelectedItem());
161
		owner.setFieldSense(cmbSenseField.getSelectedItem().equals(nullValue)?
162
				null : (String) cmbSenseField.getSelectedItem());
163
		owner.setFieldCost(cmbCostField.getSelectedItem().equals(useLineLengthItem)?
184
			cmbLengthField.setEnabled(true);
185
		} else {
186
			owner.setLengthField(null);
187
			cmbLengthField.setEnabled(false);
188
		}
189

  
190
		if (chkSenseField.isSelected()) {
191
			owner.setSenseField(cmbSenseField.getSelectedItem().equals(nullValue)?
192
					null : (String) cmbSenseField.getSelectedItem());
193
			cmbSenseField.setEnabled(true);
194
		} else {
195
			owner.setSenseField(null);
196
			cmbSenseField.setEnabled(false);
197
		}
198

  
199
		if (chkCostField.isSelected()) {
200
			owner.setCostField(cmbCostField.getSelectedItem().equals(useLineLengthItem)?
164 201
				null : (String) cmbCostField.getSelectedItem());
165
		owner.setCostsUnit((String) cmbCostUnits.getSelectedItem());
202
			cmbCostField.setEnabled(true);
203
		} else {
204
			owner.setCostField(null);
205
			cmbCostField.setEnabled(false);
206
		}
207

  
208
		if (chkCostUnits.isSelected()) {
209
			owner.setCostsUnit((String) cmbCostUnits.getSelectedItem());
210
			cmbCostUnits.setEnabled(true);
211
		} else {
212
			owner.setCostsUnit(null); // TODO use unknown?
213
			cmbCostUnits.setEnabled(false);
214
		}
166 215
	}
167 216
}
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetPage3.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2  2006-10-19 15:15:27  jaume
46
* Revision 1.3  2006-10-24 08:04:41  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.2  2006/10/19 15:15:27  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.1  2006/10/19 15:12:10  jaume
50 53
* *** empty log message ***
51 54
*
......
112 115
		if (usingCosts==null) return;
113 116

  
114 117
		if (usingCosts.equals(Boolean.TRUE)) {
115
			owner.setFieldCost(
118
			owner.setCostField(
116 119
					cmbCostField.getSelectedIndex() == 0 ?
117 120
							"" : (String)cmbCostField.getSelectedItem());
118 121
			owner.setCostsUnit(
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetPage4.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2  2006-10-19 15:15:27  jaume
46
* Revision 1.3  2006-10-24 08:04:41  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.2  2006/10/19 15:15:27  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.1  2006/10/19 15:12:10  jaume
50 53
* *** empty log message ***
51 54
*
......
97 100

  
98 101
	public void actionPerformed(ActionEvent e) {
99 102
		// refresh table
100
		owner.setFieldSense(cmbSenseField.getSelectedItem().equals(nullValue)?
103
		owner.setSenseField(cmbSenseField.getSelectedItem().equals(nullValue)?
101 104
				"" : (String) cmbSenseField.getSelectedItem());
102 105
	}
103 106

  
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetWizard.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2  2006-10-20 12:02:50  jaume
46
* Revision 1.3  2006-10-24 08:04:41  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.2  2006/10/20 12:02:50  jaume
47 50
* GUI
48 51
*
49 52
* Revision 1.1  2006/10/19 15:12:10  jaume
......
152 155
    	return layerFieldNames;
153 156
    }
154 157

  
155
    public void setFieldLength(String lengthField) {
158
    public void setLengthField(String lengthField) {
156 159
        this.fieldLength = lengthField;
157 160
    }
158 161

  
159
	public void setFieldType(String fieldType) {
162
	public void setTypeField(String fieldType) {
160 163
		this.fieldType = fieldType;
161 164
	}
162 165

  
163
	public void setFieldCost(String fieldCost) {
166
	public void setCostField(String fieldCost) {
164 167
        this.fieldCost = fieldCost;
165 168
    }
166 169

  
167
	public void setFieldSense(String fieldSense) {
170
	public void setSenseField(String fieldSense) {
168 171
		this.fieldSense = fieldSense;
169 172
	}
170 173

  

Also available in: Unified diff