• R/O
  • HTTP
  • SSH
  • HTTPS

tmdmaker: Commit

TMD-Maker(T字形ER図作成ツール)のEclipse Plugin,RCP,Webサイト用


Commit MetaInfo

Revision1020928c51a54600de6d3e7200ef0ad0cd2aac20 (tree)
Time2010-01-09 13:55:30
Authornakag <nakag@user...>
Commiternakag

Log Message

サブセットとみなしスーパーセットのタイプをリファクタリング

Change Summary

Incremental Difference

--- a/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/SubsetTypeEditPart.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/SubsetTypeEditPart.java
@@ -40,7 +40,6 @@ public class SubsetTypeEditPart extends AbstractEntityEditPart {
4040 */
4141 @Override
4242 protected IFigure createFigure() {
43- // Figure figure = new Label("=");
4443 Figure figure = new SubsetTypeFigure();
4544 updateFigure(figure);
4645 return figure;
@@ -56,7 +55,7 @@ public class SubsetTypeEditPart extends AbstractEntityEditPart {
5655 protected void updateFigure(IFigure figure) {
5756 SubsetTypeFigure sf = (SubsetTypeFigure) figure;
5857 SubsetType model = (SubsetType) getModel();
59- sf.setSubsetTypeValue(model.getSubsetType());
58+ sf.setSameType(model.isSameType());
6059 }
6160
6261 /**
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/VirtualSupersetAggregatorEditPart.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/VirtualSupersetAggregatorEditPart.java
@@ -17,14 +17,12 @@ package jp.sourceforge.tmdmaker.editpart;
1717
1818 import java.beans.PropertyChangeEvent;
1919
20+import jp.sourceforge.tmdmaker.figure.SubsetTypeFigure;
2021 import jp.sourceforge.tmdmaker.model.VirtualSupersetAggregator;
2122
22-import org.eclipse.draw2d.AbstractBorder;
2323 import org.eclipse.draw2d.ConnectionAnchor;
2424 import org.eclipse.draw2d.Figure;
25-import org.eclipse.draw2d.Graphics;
2625 import org.eclipse.draw2d.IFigure;
27-import org.eclipse.draw2d.geometry.Insets;
2826
2927 /**
3028 * みなしスーパーセットの同一(=)/相違マーク(×)のコントローラ
@@ -41,14 +39,11 @@ public class VirtualSupersetAggregatorEditPart extends AbstractEntityEditPart {
4139 */
4240 @Override
4341 protected void updateFigure(IFigure figure) {
42+ SubsetTypeFigure sf = (SubsetTypeFigure) figure;
4443 VirtualSupersetAggregator model = (VirtualSupersetAggregator) getModel();
45- ((AggregatorBorder)figure.getBorder()).setSameType(model.isApplyAttribute());
46- if (model.isApplyAttribute()) {
47- figure.setSize(30, 5);
48- } else {
49- figure.setSize(30, 10);
50- }
44+ sf.setSameType(model.isApplyAttribute());
5145 }
46+
5247 /**
5348 *
5449 * {@inheritDoc}
@@ -60,6 +55,7 @@ public class VirtualSupersetAggregatorEditPart extends AbstractEntityEditPart {
6055 // TODO Auto-generated method stub
6156
6257 }
58+
6359 /**
6460 *
6561 * {@inheritDoc}
@@ -68,13 +64,11 @@ public class VirtualSupersetAggregatorEditPart extends AbstractEntityEditPart {
6864 */
6965 @Override
7066 protected IFigure createFigure() {
71- Figure figure = new Figure();
72- figure.setSize(20, 10);
73- figure.setOpaque(false);
74- figure.setBorder(new AggregatorBorder());
67+ Figure figure = new SubsetTypeFigure();
7568 updateFigure(figure);
7669 return figure;
7770 }
71+
7872 /**
7973 *
8074 * {@inheritDoc}
@@ -97,7 +91,6 @@ public class VirtualSupersetAggregatorEditPart extends AbstractEntityEditPart {
9791 return new CenterAnchor(getFigure());
9892 }
9993
100-
10194 /**
10295 * {@inheritDoc}
10396 *
@@ -105,117 +98,11 @@ public class VirtualSupersetAggregatorEditPart extends AbstractEntityEditPart {
10598 */
10699 @Override
107100 public void propertyChange(PropertyChangeEvent evt) {
108- if (evt.getPropertyName().equals(VirtualSupersetAggregator.PROPERTY_SUPERSET_TYPE)) {
101+ if (evt.getPropertyName().equals(
102+ VirtualSupersetAggregator.PROPERTY_SUPERSET_TYPE)) {
109103 refreshVisuals();
110104 } else {
111105 super.propertyChange(evt);
112106 }
113107 }
114-
115-
116- /**
117- *
118- * @author nakaG
119- *
120- */
121- private static class AggregatorBorder extends AbstractBorder {
122- /** Figureの長さ */
123- private int width = 1;
124- /** 同一タイプか? */
125- private boolean sameType = false;
126-
127- /**
128- * @return the width
129- */
130- public int getWidth() {
131- return width;
132- }
133-
134- /**
135- * @return the sameType
136- */
137- public boolean isSameType() {
138- return sameType;
139- }
140-
141- /**
142- * @param sameType the sameType to set
143- */
144- public void setSameType(boolean sameType) {
145- this.sameType = sameType;
146- }
147-
148- /**
149- *
150- * {@inheritDoc}
151- *
152- * @see org.eclipse.draw2d.Border#getInsets(org.eclipse.draw2d.IFigure)
153- */
154- @Override
155- public Insets getInsets(IFigure figure) {
156- return new Insets(getWidth());
157- }
158-
159- /**
160- *
161- * {@inheritDoc}
162- *
163- * @see org.eclipse.draw2d.Border#paint(org.eclipse.draw2d.IFigure,
164- * org.eclipse.draw2d.Graphics, org.eclipse.draw2d.geometry.Insets)
165- */
166- @Override
167- public void paint(IFigure figure, Graphics graphics, Insets insets) {
168- if (isSameType()) {
169- paintSameType(figure, graphics, insets);
170- } else {
171- paintDifferenceType(figure, graphics, insets);
172- }
173- }
174- /**
175- * 同一タイプを描画する
176- *
177- * @param figure
178- * The figure this border belongs to
179- * @param graphics
180- * The graphics object used for painting
181- * @param insets
182- * The insets
183- */
184- private void paintSameType(IFigure figure, Graphics graphics,
185- Insets insets) {
186- tempRect.setBounds(getPaintRectangle(figure, insets));
187- if (getWidth() % 2 != 0) {
188- tempRect.width--;
189- tempRect.height--;
190- }
191- tempRect.shrink(getWidth() / 2, getWidth() / 2);
192- graphics.setLineWidth(getWidth());
193-
194- // 同一
195- graphics.drawLine(tempRect.getTopLeft(), tempRect.getTopRight());
196- graphics.drawLine(tempRect.getBottomLeft(), tempRect
197- .getBottomRight());
198- graphics.drawLine(getPaintRectangle(figure, insets).getTop(),
199- tempRect.getCenter());
200- }
201-
202- /**
203- * 相違タイプを描画する
204- *
205- * @param figure
206- * The figure this border belongs to
207- * @param graphics
208- * The graphics object used for painting
209- * @param insets
210- * The insets
211- */
212- private void paintDifferenceType(IFigure figure,
213- Graphics graphics, Insets insets) {
214- // 相違
215- tempRect.setBounds(getPaintRectangle(figure, insets));
216- graphics.drawLine(tempRect.getTopLeft(), tempRect.getBottomRight());
217- graphics.drawLine(tempRect.getBottomLeft(), tempRect.getTopRight());
218- }
219- }
220-
221108 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/figure/SubsetTypeFigure.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/figure/SubsetTypeFigure.java
@@ -15,8 +15,6 @@
1515 */
1616 package jp.sourceforge.tmdmaker.figure;
1717
18-import jp.sourceforge.tmdmaker.model.SubsetType.SubsetTypeValue;
19-
2018 import org.eclipse.draw2d.AbstractBorder;
2119 import org.eclipse.draw2d.Figure;
2220 import org.eclipse.draw2d.Graphics;
@@ -30,11 +28,12 @@ import org.eclipse.draw2d.geometry.Insets;
3028 *
3129 */
3230 public class SubsetTypeFigure extends Figure {
31+
3332 /**
3433 * コンストラクタ
3534 */
3635 public SubsetTypeFigure() {
37- this(SubsetTypeValue.SAME);
36+ this(true);
3837 }
3938
4039 /**
@@ -43,11 +42,9 @@ public class SubsetTypeFigure extends Figure {
4342 * @param subsetTypeValue
4443 * サブセットタイプ
4544 */
46- public SubsetTypeFigure(SubsetTypeValue subsetTypeValue) {
45+ public SubsetTypeFigure(boolean sameType) {
4746 super();
48- // setSize(30, 10);
49- setSubsetTypeValue(subsetTypeValue);
50- setBorder(new SubsetBorder(subsetTypeValue));
47+ setBorder(new SubsetBorder(sameType));
5148 setOpaque(false);
5249 }
5350
@@ -57,13 +54,13 @@ public class SubsetTypeFigure extends Figure {
5754 * @param subsetTypeValue
5855 * サブセットタイプ値
5956 */
60- public void setSubsetTypeValue(SubsetTypeValue subsetTypeValue) {
61- if (subsetTypeValue.equals(SubsetTypeValue.SAME)) {
57+ public void setSameType(boolean sameType) {
58+ if (sameType) {
6259 setSize(30, 5);
6360 } else {
6461 setSize(30, 10);
6562 }
66- setBorder(new SubsetBorder(subsetTypeValue));
63+ ((SubsetBorder)getBorder()).setSameType(sameType);
6764 }
6865
6966 /**
@@ -75,18 +72,18 @@ public class SubsetTypeFigure extends Figure {
7572 private static class SubsetBorder extends AbstractBorder {
7673 /** Figureの長さ */
7774 private int width = 1;
78- /** サブセットタイプ値 */
79- private SubsetTypeValue subsetTypeValue;
75+ /** 同一タイプか? */
76+ private boolean sameType;
8077
8178 /**
8279 * コンストラクタ
8380 *
84- * @param subsetTypeValue
81+ * @param subsetType
8582 * サブセットタイプ値
8683 */
87- public SubsetBorder(SubsetTypeValue subsetTypeValue) {
84+ public SubsetBorder(boolean sameType) {
8885 super();
89- this.subsetTypeValue = subsetTypeValue;
86+ this.sameType = sameType;
9087 }
9188
9289 /**
@@ -116,7 +113,7 @@ public class SubsetTypeFigure extends Figure {
116113 */
117114 @Override
118115 public void paint(IFigure figure, Graphics graphics, Insets insets) {
119- if (subsetTypeValue.equals(SubsetTypeValue.SAME)) {
116+ if (sameType) {
120117 paintSubsetSameType(figure, graphics, insets);
121118 } else {
122119 paintSubsetDifferenceType(figure, graphics, insets);
@@ -168,5 +165,13 @@ public class SubsetTypeFigure extends Figure {
168165 graphics.drawLine(tempRect.getTopLeft(), tempRect.getBottomRight());
169166 graphics.drawLine(tempRect.getBottomLeft(), tempRect.getTopRight());
170167 }
168+
169+ /**
170+ * @param sameType the sameType to set
171+ */
172+ public void setSameType(boolean sameType) {
173+ this.sameType = sameType;
174+ }
175+
171176 }
172177 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/model/SubsetType.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/model/SubsetType.java
@@ -125,6 +125,15 @@ public class SubsetType extends ConnectableElement {
125125 }
126126
127127 /**
128+ * 同一のサブセットか?
129+ *
130+ * @return 同一サブセットの場合にtrueを返す。
131+ */
132+ public boolean isSameType() {
133+ return subsetType.equals(SubsetTypeValue.SAME);
134+ }
135+
136+ /**
128137 * オブジェクト破棄
129138 */
130139 public void dispose() {
Show on old repository browser