Revision 32 trunk/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrameText.java
FFrameText.java | ||
---|---|---|
32 | 32 |
import java.awt.geom.Rectangle2D; |
33 | 33 |
import java.awt.image.BufferedImage; |
34 | 34 |
import java.util.ArrayList; |
35 |
import java.util.List; |
|
35 | 36 |
|
36 | 37 |
import org.gvsig.andami.PluginServices; |
37 | 38 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
... | ... | |
52 | 53 |
|
53 | 54 |
public static final String PERSISTENCE_DEFINITION_NAME = "FFrameText"; |
54 | 55 |
|
56 |
private static final String TEXT_FIELD = "text"; |
|
55 | 57 |
private static final String S_FIELD = "s"; |
56 | 58 |
private static final String ISFIXED_FIELD = "isFixed"; |
57 | 59 |
private static final String FONT_FIELD = "font"; |
... | ... | |
680 | 682 |
definition.extend(manager |
681 | 683 |
.getDefinition(FFrame.PERSISTENCE_DEFINITION_NAME)); |
682 | 684 |
|
685 |
/* |
|
686 |
* field 's' is Rectangle but stored as Rectangle2D |
|
687 |
*/ |
|
683 | 688 |
definition.addDynFieldObject(S_FIELD) |
684 |
.setClassOfValue(Rectangle.class).setMandatory(true); |
|
689 |
.setClassOfValue(Rectangle2D.class).setMandatory(true); |
|
690 |
definition.addDynFieldList(TEXT_FIELD) |
|
691 |
.setClassOfValue(String.class).setMandatory(true); |
|
685 | 692 |
definition.addDynFieldBoolean(ISFIXED_FIELD).setMandatory(true); |
686 | 693 |
definition.addDynFieldObject(FONT_FIELD) |
687 | 694 |
.setClassOfValue(Font.class).setMandatory(true); |
... | ... | |
711 | 718 |
public void loadFromState(PersistentState state) |
712 | 719 |
throws PersistenceException { |
713 | 720 |
super.loadFromState(state); |
714 |
s = (Rectangle) state.get(S_FIELD); |
|
721 |
|
|
722 |
/* |
|
723 |
* field 's' is Rectangle but stored as Rectangle2D |
|
724 |
*/ |
|
725 |
Rectangle2D s_2d = (Rectangle2D) state.get(S_FIELD); |
|
726 |
s = new Rectangle( |
|
727 |
(int) s_2d.getX(), |
|
728 |
(int) s_2d.getY(), |
|
729 |
(int) s_2d.getWidth(), |
|
730 |
(int) s_2d.getHeight()); |
|
731 |
|
|
732 |
/* |
|
733 |
* the text is an arraylist of strings |
|
734 |
*/ |
|
735 |
List text_list = state.getList(TEXT_FIELD); |
|
736 |
for (int i=0; i<text_list.size(); i++) { |
|
737 |
m_text.add((String) text_list.get(i)); |
|
738 |
} |
|
739 |
|
|
715 | 740 |
m_isFixed = state.getBoolean(ISFIXED_FIELD); |
716 | 741 |
m_f = (Font) state.get(FONT_FIELD); |
717 | 742 |
m_pos = state.getInt(POS_FIELD); |
... | ... | |
733 | 758 |
@Override |
734 | 759 |
public void saveToState(PersistentState state) throws PersistenceException { |
735 | 760 |
super.saveToState(state); |
736 |
state.set(S_FIELD, s); |
|
761 |
|
|
762 |
/* |
|
763 |
* field 's' is Rectangle but stored as Rectangle2D |
|
764 |
*/ |
|
765 |
Rectangle2D s_2d = new Rectangle2D.Double( |
|
766 |
s.x, s.y, s.width, s.height); |
|
767 |
state.set(S_FIELD, s_2d); |
|
768 |
|
|
769 |
state.set(TEXT_FIELD, m_text); |
|
737 | 770 |
state.set(ISFIXED_FIELD, m_isFixed); |
738 | 771 |
state.set(FONT_FIELD, m_f); |
739 | 772 |
state.set(POS_FIELD, m_pos); |
Also available in: Unified diff