@Override protected IFigure createMain () { final Figure rootFigure = new Figure (); rootFigure.setLayoutManager ( new GridLayout ( 3, true ) ); rootFigure.add ( makeHeader (), new GridData ( GridData.BEGINNING, GridData.CENTER, true, false, 3, 1 ) ); rootFigure.add ( createSourceValue (), new GridData ( GridData.CENTER, GridData.CENTER, true, true ) ); rootFigure.add ( new Figure () ); rootFigure.add ( createTargetValue (), new GridData ( GridData.CENTER, GridData.CENTER, true, true ) ); rootFigure.add ( new Figure () ); rootFigure.add ( createCommandPanel (), new GridData ( GridData.CENTER, GridData.CENTER, true, true ) ); createRoundArrow ( rootFigure ); return rootFigure; }
private void createRoundArrow ( final Figure figure ) { final PolylineConnection c = new PolylineConnection (); c.setSourceAnchor ( new ChopboxAnchor ( this.sourceRect ) ); c.setTargetAnchor ( new ChopboxAnchor ( this.targetRect ) ); final PolygonDecoration dec = new PolygonDecoration (); dec.setTemplate ( PolygonDecoration.TRIANGLE_TIP ); c.setTargetDecoration ( dec ); final MidpointLocator typeLocator = new MidpointLocator ( c, 0 ); typeLocator.setRelativePosition ( PositionConstants.NORTH ); this.typeLabel = new Label ( "" ); //$NON-NLS-1$ c.add ( this.typeLabel, typeLocator ); figure.add ( c ); this.roundConnection = c; }
@Override protected IFigure createMain () { final Figure baseFigure = new LayeredPane (); final Layer rootFigure = new Layer (); this.connLayer = new ConnectionLayer (); this.connLayer.setAntialias ( 1 ); this.connLayer.setConnectionRouter ( ConnectionRouter.NULL ); baseFigure.add ( this.connLayer ); baseFigure.add ( rootFigure ); rootFigure.setLayoutManager ( new BorderLayout () ); rootFigure.setBackgroundColor ( ColorConstants.white ); rootFigure.add ( createArrowFigure (), BorderLayout.RIGHT ); rootFigure.add ( createEntryGrid ( this.connLayer ), BorderLayout.CENTER ); return baseFigure; }
public GridContainerController ( final SymbolController controller, final GridContainer element, final BasicViewElementFactory factory ) throws Exception { this.figure = new Figure (); final GridLayout gridLayout = new GridLayout ( element.getColumns (), element.isEqualWidth () ); gridLayout.horizontalSpacing = element.getHorizontalSpacing (); gridLayout.verticalSpacing = element.getVerticalSpacing (); gridLayout.marginHeight = element.getMarginHeight (); gridLayout.marginWidth = element.getMarginWidth (); this.figure.setLayoutManager ( gridLayout ); for ( final GridChild child : element.getChildren () ) { final Controller elementController = factory.create ( controller, child.getElement () ); final IFigure childFigure = elementController.getFigure (); this.figure.add ( childFigure, convert ( child ) ); } controller.addElement ( element, this ); }
/** * {@inheritDoc} */ @Override public void createColumnArea(final IFigure columns) { initColumnArea(columns); columns.setBorder(new MarginBorder(0, 0, 0, 0)); columns.setBackgroundColor(ColorConstants.white); columns.setOpaque(true); final Figure centerFigure = new Figure(); centerFigure.setLayoutManager(new BorderLayout()); centerFigure.setBorder(new MarginBorder(new Insets(0, 2, 0, 2))); centerFigure.add(columns, BorderLayout.CENTER); getTableFigure().add(centerFigure, BorderLayout.CENTER); }
/** * {@inheritDoc} */ @Override public void createFooter() { final IFigure footer = new Figure(); final BorderLayout footerLayout = new BorderLayout(); footer.setLayoutManager(footerLayout); footer.setBorder(new MarginBorder(new Insets(0, 2, 0, 2))); final IFigure footer1 = new Figure(); footer1.setSize(-1, 10); footer1.setBackgroundColor(Resources.VERY_LIGHT_GRAY); footer1.setOpaque(true); footer.add(footer1, BorderLayout.TOP); final IFigure footer2 = new Figure(); footer2.setSize(-1, 7); footer.add(footer2, BorderLayout.BOTTOM); getTableFigure().add(footer, BorderLayout.BOTTOM); }
/** * {@inheritDoc} */ @Override public void initTitleBar(final Figure top) { final ToolbarLayout topLayout = new ToolbarLayout(); topLayout.setMinorAlignment(OrderedLayout.ALIGN_TOPLEFT); topLayout.setStretchMinorAxis(true); top.setLayoutManager(topLayout); nameLabel = new Label(); nameLabel.setBorder(new MarginBorder(new Insets(5, 20, 5, 20))); top.add(nameLabel); final Figure separater = new Figure(); separater.setSize(-1, 1); separater.setBackgroundColor(getTextColor()); separater.setOpaque(true); top.add(separater); }
/** * {@inheritDoc} */ @Override public void createColumnArea(IFigure columns) { this.initColumnArea(columns); columns.setBorder(new MarginBorder(0, 0, 0, 0)); columns.setBackgroundColor(ColorConstants.white); columns.setOpaque(true); this.centerFigure = new Figure(); this.centerFigure.setLayoutManager(new BorderLayout()); this.centerFigure.setBorder(new MarginBorder(new Insets(0, 2, 0, 2))); centerFigure.add(columns, BorderLayout.CENTER); this.getTableFigure().add(this.centerFigure, BorderLayout.CENTER); }
/** * {@inheritDoc} */ @Override public void createFooter() { IFigure footer = new Figure(); BorderLayout footerLayout = new BorderLayout(); footer.setLayoutManager(footerLayout); footer.setBorder(new MarginBorder(new Insets(0, 2, 0, 2))); IFigure footer1 = new Figure(); footer1.setSize(-1, 10); footer1.setBackgroundColor(Resources.VERY_LIGHT_GRAY); footer1.setOpaque(true); footer.add(footer1, BorderLayout.TOP); IFigure footer2 = new Figure(); footer2.setSize(-1, 7); footer.add(footer2, BorderLayout.BOTTOM); this.getTableFigure().add(footer, BorderLayout.BOTTOM); }
/** * {@inheritDoc} */ @Override public void initTitleBar(Figure top) { ToolbarLayout topLayout = new ToolbarLayout(); topLayout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT); topLayout.setStretchMinorAxis(true); top.setLayoutManager(topLayout); this.nameLabel = new Label(); this.nameLabel.setBorder(new MarginBorder(new Insets(5, 20, 5, 20))); top.add(nameLabel); Figure separater = new Figure(); separater.setSize(-1, 1); separater.setBackgroundColor(this.getTextColor()); separater.setOpaque(true); top.add(separater); }
private static Figure createContents() { Figure contents = new Figure(); XYLayout layout = new XYLayout(); contents.setLayoutManager(layout); Button button = new Button("Hello World"); layout.setConstraint(button, new Rectangle(0, 0, -1, -1)); contents.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionevent) { setBrightness(); } }); String path = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Oryx Antelope.jpg"; image = new Image(Display.getDefault(), path); imageFigure = new ImageFigure(image); layout.setConstraint(imageFigure, new Rectangle(0, 30, -1, -1)); contents.add(imageFigure); return contents; }
/** * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals() */ @Override protected void refreshVisuals() { try { super.refreshVisuals(); int totalHeight = 0; for (int i = 0; i < getFigure().getChildren().size(); i++) { totalHeight += ((Figure) getFigure().getChildren().get(i)).getSize().height; } NotationNode notationNode = (NotationNode) getModel(); Rectangle bounds = new Rectangle(notationNode.getX(), notationNode.getY(), notationNode.getWidth(), notationNode.getHeight()); getFigure().setSize(notationNode.getWidth(), totalHeight);// notationNode.getHeight()); getFigure().setLocation(new Point(notationNode.getX(), notationNode.getY())); setLayoutConstraint(this, getFigure(), bounds); getFigure().setBackgroundColor(new Color(null, getFillColor())); } catch (Exception e) { Log.error(UMLMessage.MESSAGE_DATA_STORE_NODE_EDIT_PART_REFRESH_VISUALS_ERROR + e); } }
/** * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals() */ @Override protected void refreshVisuals() { try { super.refreshVisuals(); int totalHeight = 0; for (int i = 0; i < getFigure().getChildren().size(); i++) { totalHeight += ((Figure) getFigure().getChildren().get(i)).getSize().height; } NotationNode notationNode = (NotationNode) getModel(); Rectangle bounds = new Rectangle(notationNode.getX(), notationNode.getY(), notationNode.getWidth(), notationNode.getHeight()); getFigure().setSize(notationNode.getWidth(), totalHeight);// notationNode.getHeight()); getFigure().setLocation(new Point(notationNode.getX(), notationNode.getY())); setLayoutConstraint(this, getFigure(), bounds); getFigure().setBackgroundColor(new Color(null, getFillColor())); } catch (Exception e) { Log.error(UMLMessage.MESSAGE_CLASS_EDIT_PART_REFRESH_VISUAL_ERROR + e); } }
protected void createContents() { // Name Label nameFigure = new SyntaxColoringLabel(); nameFigure.setAlignment(PositionConstants.CENTER); this.add(nameFigure, GridDataFactory.fillDefaults().grab(true, false) .getData()); // Text compartment textCompartmentPane = new Figure(); textCompartmentPane.setLayoutManager(new StackLayout()); this.add(textCompartmentPane, GridDataFactory.fillDefaults().grab(true, true).getData()); figureCompartmentPane = new Figure(); figureCompartmentPane.setLayoutManager(new StackLayout()); this.add(figureCompartmentPane, GridDataFactory.fillDefaults().grab(true, true).getData()); }
@Override public void createFooter() { final IFigure footer = new Figure(); final BorderLayout footerLayout = new BorderLayout(); footer.setLayoutManager(footerLayout); footer.setBorder(new MarginBorder(new Insets(0, 0, 0, 0))); final IFigure footer1 = new Figure(); footer1.setSize(-1, 1); footer1.setBackgroundColor(ColorConstants.black); footer1.setOpaque(true); footer.add(footer1, BorderLayout.TOP); final IFigure footer2 = new Figure(); footer2.setSize(-1, 6); footer.add(footer2, BorderLayout.BOTTOM); getTableFigure().add(footer, BorderLayout.BOTTOM); }
@Override public void initTitleBar(Figure top) { final ToolbarLayout topLayout = new ToolbarLayout(); topLayout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT); topLayout.setStretchMinorAxis(true); top.setLayoutManager(topLayout); this.nameLabel = new Label(); nameLabel.setBorder(new MarginBorder(new Insets(5, 20, 5, 20))); top.add(nameLabel); final Figure separater = new Figure(); separater.setSize(-1, 1); separater.setBackgroundColor(getTextColor()); separater.setOpaque(true); top.add(separater); }
@Override protected IFigure createFigure() { IFigure r = new Figure(); RowDataFigureLayout layout = new RowDataFigureLayout(getTimeline().getPage()); layout.setRowElementHeight(TimelineUtils.getRowElementHeight(this)); layout.setOverlapFactor(TIMELINE_PREFERENCES.getFloat(TimelinePreferencePage.P_ROW_ELEMENT_OVERLAP)); r.setLayoutManager(layout); r.setOpaque(false); // // This tricky little method makes sure that the headers of the timeline // that correspond to this row have the same height r.addLayoutListener(new LayoutListener.Stub() { @Override public void postLayout(IFigure container) { int height = container.getBounds().height; List list = (List) getViewer().getEditPartRegistry().get(getModel()); for (Object o : list) { GraphicalEditPart ep = (GraphicalEditPart) o; Request request = new Request(REQ_ROW_DATA_LAYOUT); request.getExtendedData().put("height", height); ep.performRequest(request); } } }); return r; }
public List<EditPart> getEditPartsForRequest(final Request request) { EditPartViewer viewer = getCurrentViewer(); if (viewer == null) { return null; } Point point = getLocation(); List<EditPart> editParts = new ArrayList<EditPart>(); Set visualPartSet = viewer.getVisualPartMap().keySet(); for (Object object : visualPartSet) { if (object instanceof Figure) { Figure figure = (Figure)object; if (figure.containsPoint(point)) { EditPart editPart = (EditPart)viewer.getVisualPartMap().get(figure); if (editPart.understandsRequest(request)) { editParts.add(editPart); } } } } return editParts; }
/** * {@inheritDoc} */ public void createFooter(Figure figure) { IFigure footer = new Figure(); BorderLayout footerLayout = new BorderLayout(); footer.setLayoutManager(footerLayout); footer.setBorder(new MarginBorder(new Insets(0, 2, 0, 2))); IFigure footer1 = new Figure(); footer1.setSize(-1, 10); footer1.setBackgroundColor(VERY_LIGHT_GRAY); footer1.setOpaque(true); footer.add(footer1, BorderLayout.TOP); IFigure footer2 = new Figure(); footer2.setSize(-1, 7); footer.add(footer2, BorderLayout.BOTTOM); figure.add(footer, BorderLayout.BOTTOM); }
public IFigure createFigure() { IFigure figure = new Figure() { protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); // draw top border graphics.setForegroundColor(PaletteColorUtil.WIDGET_LIST_BACKGROUND); graphics.drawLine(getBounds().getTopLeft(), getBounds() .getTopRight()); // draw bottom border graphics.setForegroundColor(PaletteColorUtil.WIDGET_BACKGROUND_NORMAL_SHADOW_70); graphics.drawLine( getBounds().getBottomLeft().getTranslated(0, -1), getBounds().getBottomRight().getTranslated(0, -1)); } }; figure.setOpaque(true); figure.setBackgroundColor(PaletteColorUtil.WIDGET_BACKGROUND); figure.setBorder(new MarginBorder(2, 1, 1, 1)); return figure; }
/** * {@inheritDoc} */ public void initTitleBar(Figure top) { top.setLayoutManager(new BorderLayout()); Figure title = new Figure(); top.add(title, BorderLayout.TOP); title.setLayoutManager(new FlowLayout()); title.setBackgroundColor(ColorConstants.darkGreen); ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(5, 10, 5, 2))); image.setImage(Activator.getImageDescriptor(ImageResource.TABLE).createImage()); title.add(image); this.nameLabel = new Label(); this.nameLabel.setBorder(new MarginBorder(new Insets(5, 0, 5, 20))); title.add(this.nameLabel); Figure separater = new Figure(); separater.setSize(100, 100); separater.setBackgroundColor(ColorConstants.black); separater.setOpaque(false); top.add(separater, BorderLayout.BOTTOM); }
/** * This method creates and returns the figure for {@link Relation}s from type cyclic, total, acyclic, reflexive and * irreflexive, which differs from relationshipConstraint to relationshipConstraint only in the * text of the {@link Label}. A cyclic, total, acyclic, reflexive or irreflexive figure is dashed line with a * {@link Label}. * * @return conn org.eclipse.draw2d.PolylineConnection * */ private static Figure createRelationshipConstraintFigure(Relation relation, EditPart editpart) { ORMRelationshipConstraintEditPart editP = (ORMRelationshipConstraintEditPart) editpart; editP.getLabel().setText(relation.getName()); editP.setTextInitial(relation.getName()); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); conn.setConnectionRouter(new BendpointConnectionRouter()); // add label to the connection ConnectionLocator loc = new ConnectionLocator(conn, ConnectionLocator.MIDDLE); loc.setRelativePosition(PositionConstants.SOUTH); loc.setGap(5); // this is needed, because when the label would be just added the label text could be seen in // the rootModel if (editP.getRoot().getContents() instanceof ORMCompartmentEditPart) { conn.add(editP.getLabel(), loc); } return conn; }
/** * {@link Relation}s from type roleequivalence have as figure a dashed line with a white arrow * tips at both connection ends. * * @return conn org.eclipse.draw2d.PolylineConnection */ private static Figure createRoleEquivalenceFigure() { // create white arrow tip 1 PolygonDecoration poly1 = new PolygonDecoration(); poly1.setAntialias(SWT.ON); poly1.setBackgroundColor(ColorConstants.white); poly1.setScale(5, 5); // create white arrow tip 2 PolygonDecoration poly2 = new PolygonDecoration(); poly2.setAntialias(SWT.ON); poly2.setBackgroundColor(ColorConstants.white); poly2.setScale(5, 5); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); // add white arrow tip 1 conn.setTargetDecoration(poly1); // add white arrow tip 2 conn.setSourceDecoration(poly2); conn.setConnectionRouter(new BendpointConnectionRouter()); return conn; }
/** * {@link Relations}s from type roleimplication and relationshipimplication have as figure a * dashed line with a white arrow tip at target end of this connection. * * @return conn org.eclipse.draw2d.PolylineConnection */ private static Figure createRoleRelationshipImplicationFigure() { // create white arrow tip PolygonDecoration poly = new PolygonDecoration(); poly.setAntialias(SWT.ON); poly.setBackgroundColor(ColorConstants.white); poly.setScale(5, 5); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); conn.setTargetDecoration(poly); conn.setConnectionRouter(new BendpointConnectionRouter()); return conn; }
/** * * {@link Relations}s from type roleprohibition and relationshipexclusion have as figure a * dashed line with a white arrow tip at target end of this connection. * * @return conn org.eclipse.draw2d.PolylineConnection * */ private static Figure createRoleRelationshipExclusionFigure() { // create white arrow tip PolylineDecoration poly1 = new PolylineDecoration(); poly1.setTemplate(INVERTED_TRIANGLE_TIP); poly1.setAntialias(SWT.ON); poly1.setBackgroundColor(ColorConstants.black); poly1.setScale(5, 5); PolylineDecoration poly2 = new PolylineDecoration(); poly2.setTemplate(INVERTED_TRIANGLE_TIP); poly2.setAntialias(SWT.ON); poly2.setBackgroundColor(ColorConstants.black); poly2.setScale(5, 5); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); conn.setTargetDecoration(poly1); conn.setSourceDecoration(poly2); conn.setConnectionRouter(new BendpointConnectionRouter()); return conn; }
/** * {@link Relation}s from type roleprohibition have as figure a dased line with two inverted and * open arrow tips at both ends of this connection. * * @return conn org.eclipse.draw2d.PolylineConnection */ private static Figure createRoleProhibitonFigure() { PolylineDecoration poly1 = new PolylineDecoration(); poly1.setTemplate(INVERTED_TRIANGLE_TIP); poly1.setAntialias(SWT.ON); poly1.setBackgroundColor(ColorConstants.black); poly1.setScale(5, 5); PolylineDecoration poly2 = new PolylineDecoration(); poly2.setTemplate(INVERTED_TRIANGLE_TIP); poly2.setAntialias(SWT.ON); poly2.setBackgroundColor(ColorConstants.black); poly2.setScale(5, 5); PolylineConnection conn = new PolylineConnection(); conn.setAntialias(SWT.ON); conn.setLineDash(new float[] {5.0f, 5.0f}); conn.setLineStyle(SWT.LINE_CUSTOM); conn.setTargetDecoration(poly1); conn.setSourceDecoration(poly2); conn.setConnectionRouter(new BendpointConnectionRouter()); return conn; }
/** * {@inheritDoc} A Shape from type compartmenttype has as a figure a * {@link ORMCompartmentV1Figure}, when the user didn't step in it, and a * {@link ORMCompartmentV2Figure}, when the user did step in it. */ @Override protected IFigure createFigure() { final ORMGraphicalEditor editorPart = (ORMGraphicalEditor) ((DefaultEditDomain) getViewer() .getEditDomain()).getEditorPart(); Figure fig = ORMFigureFactory.createFigure(this); // when this compartment editpart is not "opened"(steped in) use as // figure // ORMCompartmentV1Figure if (fig instanceof ORMCompartmentV1Figure) { return fig; } // when this edit part is "opened"(steped in) use ORMCompartmentV2Figure else { return completeORMCompartmentV2Figure((Shape) getModel(), editorPart.getIsEditorData(), fig); } }
private static Point createCurLocation(GraphicalEditPart preEdit) { String lineBR = ConfigManager.VALUE_LIST_FALSE; Point point = null; Figure figure = (Figure) preEdit.getFigure(); if ((preEdit.getModel() instanceof BaseElement)) { lineBR = ModelHelper.getElementLineBR((BaseElement) preEdit .getModel()); } if (lineBR.equals(ConfigManager.VALUE_LIST_TRUE)) { point = new Point(30, figure.getLocation().y + figure.getSize().height - 1); } else { point = new Point(figure.getLocation().x + figure.getSize().width - 1, figure.getLocation().y); } return point; }
public ExecutionOccurrenceFigure(final IInitiatorEvent execution, final Color color) { super(); this.isGutter = execution instanceof ISystemStartEvent; final int width = isGutter ? 0 : PreferencesPlugin.getDefault().getActivationWidth(); final int height = (int) execution.duration() * PreferencesPlugin.getDefault().eventHeight(); if (!isGutter) { final IContourAttributes attributes = createAttributes(execution, color); setToolTip(new Label(attributes.getToolTipText(), attributes.getToolTipIcon())); setBackgroundColor(color); } setBounds(new Rectangle(-1, -1, width, height)); setOpaque(false); setOutline(false); setLayoutManager(new XYLayout()); final Rectangle constraint = new Rectangle(width, height, -1, -1); add(new Figure(), constraint); // Ensures the figure has the correct dimensions }
public void activate( ) { if ( handles == null ) { handles = getHandleList( ); } // IFigure layer = getLayer( CrosstabTableEditPart.CELL_HANDLE_LAYER ); IFigure layer = getLayer( LayerConstants.HANDLE_LAYER ); int size = handles.size( ); for ( int i = 0; i < size; i++ ) { Figure handle = (Figure) handles.get( i ); layer.add( handle ); } super.activate( ); }
protected IFigure createFigure( ) { Figure figure = new FirstCellFigure(); contentPane = new Figure(); ReportFlowLayout rflayout = new ReportFlowLayout( ) { public void layout( IFigure parent ) { super.layout( parent ); } }; contentPane.setLayoutManager( rflayout ); contentPane.setOpaque( false ); figure.add( contentPane ); controlFigure = new ControlFigure(this, new NothingLocator()); figure.add( controlFigure ); return figure; }
protected Dimension calculateMinimumSize( IFigure container, int wHint, int hHint ) { if ( wHint > -1 ) wHint = Math.max( 0, wHint - container.getInsets( ).getWidth( ) ); if ( hHint > -1 ) hHint = Math.max( 0, hHint - container.getInsets( ).getHeight( ) ); List list = container.getChildren( ); //Rectangle rect = container.getClientArea( ); Dimension retValue = new Dimension(); Rectangle contraint = getChildContraint( container ); for (int i=0; i<list.size( ); i++) { Figure child = (Figure)list.get( i ); Dimension min = child.getMinimumSize( (wHint-contraint.width) > 0?wHint-contraint.width:-1 , hHint ); retValue.width = retValue.width + min.width; retValue.height = Math.max( retValue.height,min.height); } retValue.width += container.getInsets( ).getWidth( ); retValue.height += container.getInsets( ).getHeight( ); //retValue.union( getBorderPreferredSize( container ) ); return retValue; }
protected Dimension calculatePreferredSize( IFigure container, int wHint, int hHint ) { if ( wHint > -1 ) wHint = Math.max( 0, wHint - container.getInsets( ).getWidth( ) ); if ( hHint > -1 ) hHint = Math.max( 0, hHint - container.getInsets( ).getHeight( ) ); List list = container.getChildren( ); //Rectangle rect = container.getClientArea( ); Dimension retValue = new Dimension(); Rectangle contraint = getChildContraint( container ); for (int i=0; i<list.size( ); i++) { Figure child = (Figure)list.get( i ); Dimension min = child.getPreferredSize( (wHint-contraint.width) > 0?wHint-contraint.width:-1 , hHint ); retValue.width = retValue.width + min.width; retValue.height = Math.max( retValue.height,min.height); } retValue.width += container.getInsets( ).getWidth( ); retValue.height += container.getInsets( ).getHeight( ); //retValue.union( getBorderPreferredSize( container ) ); return retValue; }
public void layout( IFigure container ) { List list = container.getChildren( ); Rectangle rect = container.getClientArea( ); Rectangle contraint = getChildContraint( container ); for (int i=0; i<list.size( ); i++) { Figure child = (Figure)list.get( i ); if (constraints.get( child ) == null) { child.setBounds( new Rectangle(rect.x, rect.y, rect.width-contraint.width, rect.height )); } else { child.setBounds( new Rectangle(rect.x+rect.width-contraint.width, rect.y, contraint.width, rect.height )); } } }
private void adjustLocation( ) { if (infoLabel == null) { return; } Rectangle rect = infoLabel.getBounds( ).getCopy(); Dimension dim = getDistance( ); Point p = ((Figure)infoLabel).getLocation( ).getCopy( ); if (dim.width < rect.width) { p.x = p.x - (rect.width - dim.width); } if (dim.height < rect.height + DISTANCE) { p.y = p.y + (rect.height + DISTANCE - dim.height); } infoLabel.setLocation( p ); }
/** * Calculate the size. * * @return */ protected Dimension calculateIndicatorDimension( ) { Dimension retValue = new Dimension( ); List children = getChildren( ); for ( int i = 0; i < children.size( ); i++ ) { Figure figure = (Figure) children.get( i ); if ( figure instanceof ShowSourceFigure ) { continue; } // retValue = retValue.union( figure.getSize( ) ); retValue.width = retValue.width + figure.getSize( ).width; retValue.height = Math.max( retValue.height, figure.getSize( ).height ); } return retValue; }