Revision 24219 trunk/extensions/extSymbology/src/org/gvsig/symbology/gui/layerproperties/LabelClassPreview.java
LabelClassPreview.java | ||
---|---|---|
43 | 43 |
import java.awt.BasicStroke; |
44 | 44 |
import java.awt.Color; |
45 | 45 |
import java.awt.Dimension; |
46 |
import java.awt.Font; |
|
46 | 47 |
import java.awt.Graphics; |
47 | 48 |
import java.awt.Graphics2D; |
48 | 49 |
import java.awt.Rectangle; |
... | ... | |
50 | 51 |
import javax.swing.JPanel; |
51 | 52 |
|
52 | 53 |
import com.iver.andami.PluginServices; |
53 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
54 | 54 |
import com.iver.cit.gvsig.fmap.core.styles.ILabelStyle; |
55 |
import com.iver.cit.gvsig.fmap.core.symbols.SymbolDrawingException; |
|
56 | 55 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelClass; |
57 | 56 |
|
58 | 57 |
public class LabelClassPreview extends JPanel { |
59 | 58 |
private static final long serialVersionUID = 3788548343944220354L; |
60 | 59 |
private Dimension sz = new Dimension(100, 200); |
61 | 60 |
private LabelClass labelClass; |
62 |
|
|
61 |
|
|
63 | 62 |
@Override |
64 | 63 |
public Dimension getPreferredSize() { |
65 |
Dimension sz = labelClass == null ? this.sz : labelClass.getBounds().getSize();
|
|
64 |
Dimension sz = labelClass == null ? this.sz : labelClass.getBounds().getSize(); |
|
66 | 65 |
int w = sz.width; |
67 | 66 |
int h = sz.height; |
68 |
|
|
67 |
|
|
69 | 68 |
if (w>300) { |
70 | 69 |
w = 300; |
71 | 70 |
} |
72 |
|
|
71 |
|
|
73 | 72 |
if (h>200) { |
74 | 73 |
h = 200; |
75 | 74 |
} |
... | ... | |
89 | 88 |
g.setColor(Color.black); |
90 | 89 |
((Graphics2D) g).draw(r); |
91 | 90 |
ILabelStyle sty = labelClass.getLabelStyle(); |
91 |
String cad; |
|
92 | 92 |
if (sty != null) { |
93 | 93 |
int fc = sty.getFieldCount(); |
94 | 94 |
String[] texts = new String[fc]; |
... | ... | |
99 | 99 |
} else { |
100 | 100 |
labelClass.setTexts(new String[] {PluginServices.getText(this, "text_field")}); |
101 | 101 |
} |
102 |
|
|
103 |
try { |
|
104 |
|
|
105 |
labelClass.drawInsideRectangle((Graphics2D) g, r); |
|
106 |
} catch (SymbolDrawingException e) { |
|
107 |
SymbologyFactory |
|
108 |
.getWarningSymbol( |
|
109 |
PluginServices.getText(this, |
|
110 |
"cant_draw_preview"), |
|
111 |
SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
|
112 |
SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS); |
|
113 |
} |
|
102 |
|
|
103 |
// try { |
|
104 |
// labelClass.drawInsideRectangle((Graphics2D) g, r); |
|
105 |
Font myFont = new Font(labelClass.getTextSymbol().getFont().getName(),labelClass.getTextSymbol().getFont().getStyle(),35); |
|
106 |
g.setFont(myFont); |
|
107 |
g.drawString(PluginServices.getText(this, "text_field"), 0, (int)r.getCenterY()); |
|
108 |
// } catch (SymbolDrawingException e) { |
|
109 |
// SymbologyFactory |
|
110 |
// .getWarningSymbol( |
|
111 |
// PluginServices.getText(this, |
|
112 |
// "cant_draw_preview"), |
|
113 |
// SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
|
114 |
// SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS); |
|
115 |
// } |
|
114 | 116 |
} |
115 | 117 |
|
116 | 118 |
public void setLabelClass(LabelClass labelClass) { |
Also available in: Unified diff