Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 118081 Details for
Bug 255553
Compartments should support line styles by default
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch
LineWidthTypeComp.txt (text/plain), 17.33 KB, created by
Lidija Grahek
on 2008-11-17 13:52:48 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Lidija Grahek
Created:
2008-11-17 13:52:48 EST
Size:
17.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.runtime.diagram.ui.geoshapes >Index: src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/draw2d/figures/GeoShapeLineStyleBorder.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.geoshapes/src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/draw2d/figures/GeoShapeLineStyleBorder.java,v >retrieving revision 1.1 >diff -u -r1.1 GeoShapeLineStyleBorder.java >--- src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/draw2d/figures/GeoShapeLineStyleBorder.java 3 May 2008 20:56:26 -0000 1.1 >+++ src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/draw2d/figures/GeoShapeLineStyleBorder.java 17 Nov 2008 18:40:48 -0000 >@@ -1,5 +1,5 @@ > /****************************************************************************** >- * Copyright (c) 2002, 2004 IBM Corporation and others. >+ * Copyright (c) 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -18,15 +18,13 @@ > import org.eclipse.draw2d.geometry.Rectangle; > > /** >- * Extends {@link org.eclipse.draw2d.LineBorder} to support line style. >+ * Extends {@link org.eclipse.draw2d.LineBorder} to customize painting. > * > * @author Anthony Hunter > * @since 2.1 > */ > public class GeoShapeLineStyleBorder extends LineBorder { > >- private int style = Graphics.LINE_SOLID; >- > /** > * Constructs a default black LineBorder with a width of one pixel. > * >@@ -36,25 +34,6 @@ > super(); > } > >- /** >- * Get the line style of this border. >- * >- * @return The line style of this border. >- */ >- public int getStyle() { >- return style; >- } >- >- /** >- * Set the line style of this border. >- * >- * @param style >- * The line style of this border. >- */ >- public void setStyle(int style) { >- this.style = style; >- } >- > /* > * @see org.eclipse.draw2d.LineBorder#paint(org.eclipse.draw2d.IFigure, > * org.eclipse.draw2d.Graphics, org.eclipse.draw2d.geometry.Insets) >Index: src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/editparts/ShadowRectangleEditPart.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.geoshapes/src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/editparts/ShadowRectangleEditPart.java,v >retrieving revision 1.5 >diff -u -r1.5 ShadowRectangleEditPart.java >--- src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/editparts/ShadowRectangleEditPart.java 4 Nov 2005 22:13:11 -0000 1.5 >+++ src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/editparts/ShadowRectangleEditPart.java 17 Nov 2008 18:40:48 -0000 >@@ -47,5 +47,23 @@ > public IFigure getContentPane() { > return ((GeoShapeFigure) getFigure()).getContentPane(); > } >+ >+ /** >+ * Sets the line width to the border as well. >+ * @see org.eclipse.gmf.runtime.diagram.ui.geoshapes.internal.editparts.GeoShapeEditPart#setLineWidth(int) >+ */ >+ protected void setLineWidth(int width) { >+ super.setLineWidth(width); >+ ((RectangularDropShadowLineBorder)getFigure().getBorder()).setWidth(getMapMode().DPtoLP(width)); >+ getFigure().revalidate(); >+ } >+ >+ /** Sets the line type to the border. >+ * @see org.eclipse.gmf.runtime.diagram.ui.geoshapes.internal.editparts.GeoShapeEditPart#setLineType(int) >+ */ >+ protected void setLineType(int lineType) { >+ super.setLineType(lineType); >+ ((RectangularDropShadowLineBorder)getFigure().getBorder()).setStyle(lineType); >+ } > > } >#P org.eclipse.gmf.runtime.diagram.ui >Index: src/org/eclipse/gmf/runtime/diagram/ui/editparts/ResizableCompartmentEditPart.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/editparts/ResizableCompartmentEditPart.java,v >retrieving revision 1.15 >diff -u -r1.15 ResizableCompartmentEditPart.java >--- src/org/eclipse/gmf/runtime/diagram/ui/editparts/ResizableCompartmentEditPart.java 3 Oct 2006 15:02:04 -0000 1.15 >+++ src/org/eclipse/gmf/runtime/diagram/ui/editparts/ResizableCompartmentEditPart.java 17 Nov 2008 18:40:49 -0000 >@@ -1,5 +1,5 @@ > /****************************************************************************** >- * Copyright (c) 2002, 2006 IBM Corporation and others. >+ * Copyright (c) 2002, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -11,7 +11,9 @@ > > package org.eclipse.gmf.runtime.diagram.ui.editparts; > >+import org.eclipse.draw2d.Border; > import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.LineBorder; > import org.eclipse.emf.common.notify.Notification; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.gef.ExposeHelper; >@@ -70,6 +72,8 @@ > refreshShowCompartmentTitle(); > refreshCollapsed(); > refreshRatio(); >+ refreshLineWidth(); >+ refreshLineType(); > } > > /** >@@ -138,7 +142,11 @@ > NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || > NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { > refreshFont(); >- } else >+ } else if (NotationPackage.eINSTANCE.getLineStyle_LineWidth().equals(feature)){ >+ refreshLineWidth(); >+ } else if (NotationPackage.eINSTANCE.getLineTypeStyle_LineType().equals(feature)) { >+ refreshLineType(); >+ } else > super.handleNotificationEvent(event); > } > >@@ -229,6 +237,30 @@ > if (getCompartmentFigure()!=null) > getCompartmentFigure().setFontColor(color); > } >+ >+ /** >+ * Sets the line width for the shape's border >+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#setLineWidth(int) >+ */ >+ protected void setLineWidth(int width) { >+ Border border = getFigure().getBorder(); >+ if (border instanceof LineBorder) { >+ ((LineBorder) border).setWidth(getMapMode().DPtoLP(width)); >+ getFigure().revalidate(); >+ } >+ } >+ >+ /** >+ * Sets the line type for the shape's border >+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#setLineType(int) >+ */ >+ protected void setLineType(int type) { >+ Border border = getFigure().getBorder(); >+ if (border instanceof LineBorder) { >+ ((LineBorder) border).setStyle(type); >+ //getFigure().repaint(); >+ } >+ } > > /** > * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#addNotationalListeners() >#P org.eclipse.draw2d >Index: src/org/eclipse/draw2d/LineBorder.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/LineBorder.java,v >retrieving revision 1.7 >diff -u -r1.7 LineBorder.java >--- src/org/eclipse/draw2d/LineBorder.java 30 Mar 2005 21:27:45 -0000 1.7 >+++ src/org/eclipse/draw2d/LineBorder.java 17 Nov 2008 18:40:49 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -23,6 +23,23 @@ > > private int width = 1; > private Color color; >+private int style = Graphics.LINE_SOLID; >+ >+/** >+ * Constructs a LineBorder with the specified color and of the specified width and style. >+ * >+ * @param color The color of the border. >+ * @param width The width of the border in pixels. >+ * @param style The style of the border. For the list of valid values, see >+ * {@link org.eclipse.draw2d.Graphics} >+ * @since 3.5 >+ */ >+public LineBorder(Color color, int width, int style) { >+ setColor(color); >+ setWidth(width); >+ setStyle(style); >+} >+ > > /** > * Constructs a LineBorder with the specified color and of the specified width. >@@ -32,8 +49,7 @@ > * @since 2.0 > */ > public LineBorder(Color color, int width) { >- setColor(color); >- setWidth(width); >+ this(color, width, Graphics.LINE_SOLID); > } > > /** >@@ -109,6 +125,7 @@ > } > tempRect.shrink(getWidth() / 2, getWidth() / 2); > graphics.setLineWidth(getWidth()); >+ graphics.setLineStyle(getStyle()); > if (getColor() != null) > graphics.setForegroundColor(getColor()); > graphics.drawRectangle(tempRect); >@@ -127,7 +144,27 @@ > * @param width The line width > */ > public void setWidth(int width) { >- this.width = width; >+ if (width > 0) { >+ this.width = width; >+ } >+} >+ >+/** >+ * Returns the line style for this border. >+ * @return The line style for this border >+ * @since 3.5 >+ */ >+public int getStyle() { >+ return style; >+} >+ >+/** >+ * Sets the line type of this border. >+ * @param style For the list of valid values, see {@link org.eclipse.draw2d.Graphics} >+ * @since 3.5 >+ */ >+public void setStyle(int style) { >+ this.style = style; > } > > } >#P org.eclipse.gmf.runtime.draw2d.ui >Index: src/org/eclipse/gmf/runtime/draw2d/ui/figures/OneLineBorder.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.draw2d.ui/src/org/eclipse/gmf/runtime/draw2d/ui/figures/OneLineBorder.java,v >retrieving revision 1.2 >diff -u -r1.2 OneLineBorder.java >--- src/org/eclipse/gmf/runtime/draw2d/ui/figures/OneLineBorder.java 12 Sep 2005 21:27:42 -0000 1.2 >+++ src/org/eclipse/gmf/runtime/draw2d/ui/figures/OneLineBorder.java 17 Nov 2008 18:40:49 -0000 >@@ -1,5 +1,5 @@ > /****************************************************************************** >- * Copyright (c) 2002, 2003 IBM Corporation and others. >+ * Copyright (c) 2002, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -117,19 +117,31 @@ > tempRect.width--; > tempRect.height--; > } >- tempRect.shrink(getWidth() / 2, getWidth() / 2); > graphics.setLineWidth(getWidth()); >+ graphics.setLineStyle(getStyle()); > switch (position) { > case PositionConstants.TOP : >- graphics.drawLine(tempRect.getTopLeft(), tempRect.getTopRight()); >+ // move down by width/2 to ensure the border will fit; >+ // no need to change x >+ tempRect.y += getWidth() / 2; >+ graphics.drawLine(tempRect.getTopLeft(), tempRect.getTopRight()); > break; >- case PositionConstants.BOTTOM : >+ case PositionConstants.BOTTOM : >+ // move up by width/2 to ensure the border will fit; >+ // no need to change x >+ tempRect.y -= getWidth() / 2; > graphics.drawLine(tempRect.getBottomLeft(), tempRect.getBottomRight()); > break; > case PositionConstants.LEFT : >+ // move right by width/2 to ensure the border will fit; >+ // no need to change y >+ tempRect.x += getWidth() / 2; > graphics.drawLine(tempRect.getTopLeft(), tempRect.getBottomLeft()); > break; > case PositionConstants.RIGHT : >+ // move left by width/2 to ensure the border will fit; >+ // no need to change y >+ tempRect.x -= getWidth() / 2; > graphics.drawLine(tempRect.getTopRight(), tempRect.getBottomRight()); > break; > } >Index: src/org/eclipse/gmf/runtime/draw2d/ui/figures/RectangularDropShadowLineBorder.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.draw2d.ui/src/org/eclipse/gmf/runtime/draw2d/ui/figures/RectangularDropShadowLineBorder.java,v >retrieving revision 1.6 >diff -u -r1.6 RectangularDropShadowLineBorder.java >--- src/org/eclipse/gmf/runtime/draw2d/ui/figures/RectangularDropShadowLineBorder.java 3 Oct 2006 15:04:52 -0000 1.6 >+++ src/org/eclipse/gmf/runtime/draw2d/ui/figures/RectangularDropShadowLineBorder.java 17 Nov 2008 18:40:49 -0000 >@@ -1,5 +1,5 @@ > /****************************************************************************** >- * Copyright (c) 2002, 2004 IBM Corporation and others. >+ * Copyright (c) 2002, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -42,7 +42,7 @@ > * Constructs a LineBorder > * of the specified width. > * >- * @param w Width of inset for border >+ * @param w Width of inset for border in logic points > * > */ > public RectangularDropShadowLineBorder(int w) { >@@ -90,11 +90,11 @@ > * @return Insets the Insets for the border on the given figure. > */ > public Insets getInsets(IFigure figure) { >- Insets insetsNew = super.getInsets(figure); >- insetsNew.top = 0; >- insetsNew.left = 0; >- insetsNew.bottom = MapModeUtil.getMapMode(figure).DPtoLP(insetsNew.bottom + getShadowHeight()); >- insetsNew.right = MapModeUtil.getMapMode(figure).DPtoLP(insetsNew.right + getShadowWidth()); >+ // take into account line width >+ Insets insetsNew = new Insets(getWidth()); >+ IMapMode mm = MapModeUtil.getMapMode(figure); >+ insetsNew.bottom += mm.DPtoLP(getShadowHeight()); >+ insetsNew.right += mm.DPtoLP(getShadowWidth()); > > return insetsNew; > } >@@ -153,12 +153,13 @@ > * @param insets Insets value that contrains how the border will be painted. > */ > public void paintLineBorder(IFigure figure, Graphics g, Insets insets) { >- > // will not paint line border if width is 0 > if (getWidth() > 0) { > tempRect.setBounds(getPaintRectangle(figure, insets)); >+ tempRect.shrink(getWidth()/2, getWidth()/2); > g.setLineWidth(getWidth()); >- g.drawRectangle(tempRect); >+ g.setLineStyle(getStyle()); >+ g.drawRectangle(tempRect); > } > } > >@@ -182,12 +183,9 @@ > tempRect.setBounds(getPaintRectangle(figure, insets)); > tempRect.width -= mm.DPtoLP(getShadowWidth()); > tempRect.height -= mm.DPtoLP(getShadowHeight()); >- if (getWidth() % 2 == 1) { >- tempRect.width -= mm.DPtoLP(1); >- tempRect.height -= mm.DPtoLP(1); >- } >- tempRect.shrink(mm.DPtoLP(getWidth() / 2), mm.DPtoLP(getWidth() / 2)); >+ tempRect.shrink(getWidth() / 2, getWidth() / 2); > g.setLineWidth(getWidth()); >+ g.setLineStyle(getStyle()); > > if (getColor() != null) { > g.setForegroundColor(getColor()); >@@ -202,7 +200,7 @@ > * Overridden method for painting the border on the shape. > * @param figure Figure that the border will be painted on > * @param g Graphics context >- * @param insets Insets value that contrains how the border will be painted. >+ * @param insets Insets value that constrains how the border will be painted. > */ > public void paint(IFigure figure, Graphics g, Insets insets) { > >@@ -233,7 +231,7 @@ > } > > /** >- * @return Returns the drip shadow iamge. >+ * @return Returns the drop shadow image. > */ > protected RectangularDropShadow getDropShadow() { > return dropShadow; >Index: src/org/eclipse/gmf/runtime/draw2d/ui/internal/figures/LineBorderEx.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.draw2d.ui/src/org/eclipse/gmf/runtime/draw2d/ui/internal/figures/LineBorderEx.java,v >retrieving revision 1.3 >diff -u -r1.3 LineBorderEx.java >--- src/org/eclipse/gmf/runtime/draw2d/ui/internal/figures/LineBorderEx.java 4 Nov 2005 21:27:59 -0000 1.3 >+++ src/org/eclipse/gmf/runtime/draw2d/ui/internal/figures/LineBorderEx.java 17 Nov 2008 18:40:49 -0000 >@@ -1,5 +1,5 @@ > /****************************************************************************** >- * Copyright (c) 2002, 2004 IBM Corporation and others. >+ * Copyright (c) 2002, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -16,6 +16,7 @@ > import org.eclipse.draw2d.IFigure; > import org.eclipse.draw2d.LineBorder; > import org.eclipse.draw2d.geometry.Insets; >+import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode; > import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil; > import org.eclipse.swt.graphics.Color; > >@@ -70,14 +71,13 @@ > */ > public void paint(IFigure figure, Graphics graphics, Insets insets) { > tempRect.setBounds(getPaintRectangle(figure, insets)); >- if (getWidth() % 2 == 1) { >- tempRect.width -= MapModeUtil.getMapMode(figure).DPtoLP(1); >- tempRect.height -= MapModeUtil.getMapMode(figure).DPtoLP(1); >- } >- int shrinkWidth = MapModeUtil.getMapMode(figure).DPtoLP( getWidth() / 2 ); >- tempRect.shrink(shrinkWidth, shrinkWidth); >+ IMapMode mm = MapModeUtil.getMapMode(figure); >+ // width is in pixels (as stated in constructors), convert it >+ int lpWidth = mm.DPtoLP(getWidth()); >+ tempRect.shrink(lpWidth / 2, lpWidth / 2); > >- graphics.setLineWidth(getWidth()); >+ graphics.setLineWidth(lpWidth); >+ graphics.setLineStyle(getStyle()); > if (getColor() != null) > graphics.setForegroundColor(getColor()); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 255553
:
118081
|
120259