/** * createContents * void */ private void createContents() { setLayoutManager(new CombinedFragmentLayout()); setBorder(new LineBorder(0)); setFill(false); setXOR(false); fragmentBoundary = new Polygon(); fragmentBoundary.setFill(true); fragmentBoundary.setBackgroundColor(UiCorePlugin.getDefault().getColor(IConstantColorRegistry.LightGray)); this.add(fragmentBoundary); fragmentLabel = new Label("None"); this.add(fragmentLabel); }
@Override public void setConstraint(IFigure child, Object constraint) { if(constraint.equals(SCALE)) scale = (RoundScale)child; else if (constraint.equals(RAMP)) ramp = (RoundScaledRamp) child; else if (constraint.equals(NEEDLE)) needle = (Polygon) child; else if (constraint.equals(VALUE_LABEL)) valueLabel = (Label)child; }
@Override protected void customizeFigure() { diamond = new Polygon(); diamond.setLineWidth(1); add(diamond, 0); setSize(50, 50); diamond.setPoints(calculatePointList()); }
private Polygon getPolygon( Object model ) { Polygon polygon = new Polygon( ); int x = getPosX( model ); int y = getPosY( model ); int width = getWidth( model ); int height = getHeight( model ); polygon.addPoint( new Point( x - 50, y - 50 ) ); polygon.addPoint( new Point( x + width + 50, y - 50 ) ); polygon.addPoint( new Point( x + width + 50, y + height + 50 ) ); polygon.addPoint( new Point( x - 50, y + height + 50 ) ); return polygon; }
protected void refreshVisuals( ) { Rectangle r; if ( !UIHelper.existIntProperty( ( (ReportElementHandle) getModel( ) ).getRoot( ), UIHelper.getId( getModel( ), cube ), BuilderConstants.POSITION_X ) ) { int displayWidth = 500 - 40; int displayHeight = 400 - 20; List childList = new ArrayList( ); if ( getCube( ) != null ) { childList.add( getCube( ).getDataSet( ) ); DimensionHandle[] dimensions = (DimensionHandle[]) getCube( ).getContents( ICubeModel.DIMENSIONS_PROP ) .toArray( new DimensionHandle[0] ); for ( int i = 0; i < dimensions.length; i++ ) { TabularHierarchyHandle hierarchy = (TabularHierarchyHandle) dimensions[i].getDefaultHierarchy( ); if ( hierarchy != null && hierarchy.getDataSet( ) != null ) childList.add( hierarchy ); } } List polygonList = new ArrayList( ); for ( int i = 0; i < childList.size( ); i++ ) { if ( existPosX( childList.get( i ) ) ) polygonList.add( getPolygon( childList.get( i ) ) ); } int width = getWidth( getModel( ) ); int height = getHeight( getModel( ) ); boolean contain = false; int x = 0, y = 0; for ( int i = 0; i < 100; i++ ) { x = new Random( ).nextInt( displayWidth - width ); y = new Random( ).nextInt( displayHeight - height ); for ( int j = 0; j < polygonList.size( ); j++ ) { contain = true; Polygon polygon = (Polygon) polygonList.get( j ); if ( polygon.containsPoint( x, y ) ) break; if ( polygon.containsPoint( x + width, y ) ) break; if ( polygon.containsPoint( x + width, y + height ) ) break; if ( polygon.containsPoint( x, y + height ) ) break; contain = false; } if ( !contain ) { break; } } polygonList.clear( ); childList.clear( ); if ( !contain ) r = new Rectangle( setPosX( x ), setPosY( y ), width, height ); else r = new Rectangle( getPosX( getModel( ) ), getPosY( getModel( ) ), getWidth( getModel( ) ), getHeight( getModel( ) ) ); } else r = new Rectangle( getPosX( getModel( ) ), getPosY( getModel( ) ), getWidth( getModel( ) ), getHeight( getModel( ) ) ); getFigure( ).setBounds( r ); ( (GraphicalEditPart) getParent( ) ).setLayoutConstraint( this, getFigure( ), r ); }