protected void handleResize ( final Rectangle bounds ) { if ( !isZooming () ) { final org.eclipse.draw2d.geometry.Rectangle r = new org.eclipse.draw2d.geometry.Rectangle ( bounds.x, bounds.y, bounds.width, bounds.height ); this.connectionLayer.setPreferredSize ( r.getSize () ); setZoom ( 1.0 ); return; } final Dimension prefSize = getPreferredSize ( bounds ); final double ar = prefSize.preciseWidth () / prefSize.preciseHeight (); double newHeight = bounds.width / ar; final double zoom; if ( newHeight > bounds.height ) { newHeight = bounds.height; } zoom = newHeight / prefSize.preciseHeight (); setZoom ( zoom ); }
public void update(Object array) { this.array = array; valid = model.isMatrix(); if(valid) { Dimension dim = model.getMatrixDimension(); width = dim.width; height = dim.height; // width = Array.getLength(Array.get(array, 0)); // height = Array.getLength(array); } else { width = 200; height = 50; } setSize(width+2, height+2); repaint(); }
@Override public void prepareUIXML() { join = (Join) typeBaseComponent; super.prepareUIXML(); LOGGER.debug("Fetching Join-Properties for -{}", componentName); if(inPortCounter<=2){ inPortCounter = 2; } propertyMap.put(Constants.UNUSED_AND_INPUT_PORT_COUNT_PROPERTY, String.valueOf(inPortCounter)); propertyMap.put(Constants.INPUT_PORT_COUNT_PROPERTY, String.valueOf(inPortCounter)); propertyMap.put(Constants.UNUSED_PORT_COUNT_PROPERTY, String.valueOf(inPortCounter)); propertyMap.put(Constants.OUTPUT_PORT_COUNT_PROPERTY, String.valueOf(1)); propertyMap.put(Constants.JOIN_CONFIG_FIELD, getJoinConfigProperty()); container.getComponentNextNameSuffixes().put(name_suffix, 0); container.getComponentNames().add(componentName); uiComponent.setProperties(propertyMap); uiComponent.setType(UIComponentsConstants.JOIN.value()); uiComponent.setSize(new Dimension(((inPortCounter+1)*33), ((inPortCounter+1)*27) + 16)); }
@Override public void prepareUIXML() { super.prepareUIXML(); partitionByExpression = (PartitionByExpression) typeBaseComponent; if (outPortCounter == 0) { outPortCounter = 2; } propertyMap.put(Constants.OUTPUT_PORT_COUNT_PROPERTY, String.valueOf(outPortCounter)); propertyMap.put(PropertyNameConstants.FILTER_LOGIC.value(), getOperationClassOrExpression()); container.getComponentNextNameSuffixes().put(name_suffix, 0); container.getComponentNames().add(componentName); uiComponent.setProperties(propertyMap); uiComponent.setType(UIComponentsConstants.PARTITION_BY_EXPRESSION.value()); uiComponent.setSize(new Dimension(100, ((outPortCounter + 1) * 27) + 16)); }
/** * Update sub graph model properties. * * @param edComponentEditPart * the ed component edit part * @param inPort * the in port * @param outPort * the out port * @param file * the file */ public void updateSubJobModelProperties(ComponentEditPart edComponentEditPart, int inPort, int outPort, IFile file) { edComponentEditPart.getCastedModel().completeInputPortSettings(inPort); edComponentEditPart.getCastedModel().completeOutputPortSettings(outPort); ComponentFigure compFig = (ComponentFigure) edComponentEditPart.getFigure(); compFig.setHeight(inPort, outPort); Dimension newSize = new Dimension(compFig.getWidth(), compFig.getHeight() + edComponentEditPart.getCastedModel().getComponentLabelMargin()); edComponentEditPart.getCastedModel().setSize(newSize); String subJobFilePath = file.getFullPath().toString(); edComponentEditPart.getCastedModel().getProperties().put(Constants.PATH, subJobFilePath.substring(1)); if (inPort != 0 && outPort != 0) edComponentEditPart.getCastedModel().getProperties().put(Constants.TYPE, Constants.OPERATION); if (inPort != 0 && outPort == 0) edComponentEditPart.getCastedModel().getProperties().put(Constants.TYPE, Constants.OUTPUT); if (inPort == 0 && outPort != 0) edComponentEditPart.getCastedModel().getProperties().put(Constants.TYPE, Constants.INPUT); if (inPort == 0 && outPort == 0) edComponentEditPart.getCastedModel().getProperties().put(Constants.TYPE, Constants.STANDALONE_SUBJOB); edComponentEditPart.refresh(); }
private Object createCommentBox(Event event) { CommentBox commentBox = null; editor = (ELTGraphicalEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor(); if (editor != null) { Container container = editor.getContainer(); checkComponentCoordinates(event, container); org.eclipse.draw2d.geometry.Point point = new org.eclipse.draw2d.geometry.Point(event.x, event.y); commentBox = new CommentBox(LABEL); commentBox.setSize(new Dimension(300, 60)); commentBox.setLocation(point); CommentBoxCommand command = new CommentBoxCommand(commentBox, LABEL, container); command.execute(); } return commentBox; }
@Override protected void paintFigure(Graphics g) { super.paintFigure(g); Rectangle r = getBounds(); Rectangle square = new Rectangle(r.getLocation().getTranslated(0, r.height/4), new Dimension(r.width/2, r.height/2)); center = new Point(square.x + square.width/2, square.y + square.height/2); g.setBackgroundColor(dirty ? PandionJConstants.Colors.HIGHLIGHT : PandionJConstants.Colors.VARIABLE_BOX); g.fillRectangle(square); g.setForegroundColor(ref.getRole() == Role.FIXED_VALUE ? PandionJConstants.Colors.CONSTANT : ColorConstants.black); g.drawRectangle(square); g.setBackgroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black); g.fillOval(center.x-3, center.y-3, 7, 7); if(isnull) { g.setForegroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black); Point dest = center.getTranslated(20, 0); g.drawLine(center, dest); g.drawLine(dest.getTranslated(-3, 5), dest.getTranslated(3, -5)); } }
public void updateLayout() { if(!canvas.isDisposed()) { Dimension size = rootFig.getPreferredSize(); canvas.setSize(size.width, size.height); org.eclipse.draw2d.GridData d = (org.eclipse.draw2d.GridData) rootGrid.getConstraint(stackFig); d.widthHint = Math.max(PandionJConstants.STACKCOLUMN_MIN_WIDTH, stackFig.getPreferredSize().width); rootGrid.layout(rootFig); requestLayout(); } }
private Dimension getPreferredSize ( final Rectangle bounds ) { if ( this.symbol != null && this.symbol.getDesignSize () != null ) { return new PrecisionDimension ( this.symbol.getDesignSize ().getWidth (), this.symbol.getDesignSize ().getHeight () ); } else if ( this.figure != null ) { return this.figure.getPreferredSize ( bounds.width, bounds.height ); } else { return new PrecisionDimension ( bounds.width, bounds.height ); } }
@Override protected IFigure createFigure() { ComponentImplementationNode model = (ComponentImplementationNode) getModel(); ComponentImplementationFigure figure = new ComponentImplementationFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); return figure; }
@Override protected void refreshVisuals() { ComponentImplementationNode model = (ComponentImplementationNode) getModel(); ComponentImplementationFigure figure = (ComponentImplementationFigure) getFigure(); figure.setNode(model); figure.setBounds(model.getConstraints()); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); }
@Override protected IFigure createFigure() { DeploymentNode model = (DeploymentNode) getModel(); DeploymentFigure figure = new DeploymentFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); return figure; }
@Override protected void refreshVisuals() { DeploymentNode model = (DeploymentNode) getModel(); DeploymentFigure figure = (DeploymentFigure) getFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); }
@Override protected IFigure createFigure() { LogicalSystemNode model = (LogicalSystemNode) getModel(); LogicalSystemFigure figure = new LogicalSystemFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); return figure; }
@Override protected void refreshVisuals() { LogicalSystemNode model = (LogicalSystemNode) getModel(); LogicalSystemFigure figure = (LogicalSystemFigure) getFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); }
@Override protected IFigure createFigure() { CompositeNode model = (CompositeNode) getModel(); CompositeFigure figure = new CompositeFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); return figure; }
@Override protected void refreshVisuals() { CompositeNode model = (CompositeNode) getModel(); CompositeFigure figure = (CompositeFigure) getFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); }
@Override protected IFigure createFigure() { CompositeNode model = (CompositeNode) getModel(); CompositeFigure figure = new CompositeFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.rebuildFigure(); return figure; }
@Override public Dimension getPreferredSize(int w, int h) { Dimension d = super.getPreferredSize(-1, -1); if (d.width > 150) d = super.getPreferredSize(150, -1); return d; }
private void adjustComponentFigure(Component component) { Font font = new Font( Display.getDefault(), ModelConstants.labelFont, 10, SWT.NORMAL ); int labelLength = TextUtilities.INSTANCE.getStringExtents(component.getComponentLabel().getLabelContents(), font).width; if(labelLength >= ModelConstants.compLabelOneLineLengthLimit && component.getSize().height<96 ){ component.setSize(new Dimension(component.getSize().width, component.getSize().height + ModelConstants.componentOneLineLabelMargin)); ComponentLabel componentLabel = component.getComponentLabel(); componentLabel.setSize(new Dimension(componentLabel.getSize().width, componentLabel.getSize().height + ModelConstants.componentOneLineLabelMargin)); component.setComponentLabelMargin(ModelConstants.componentTwoLineLabelMargin); } }
/** * Sets the size. * * @param d * the new size */ public void setSize(Dimension d) { if (size.equals(d)) return; size = d; firePropertyChange("compLabelSize", null, size); }
/** * Instantiates a new component. */ public Component() { location = new Point(0, 0); size = new Dimension(100, 80); properties = new LinkedHashMap<>(); subJobContainer= new LinkedHashMap<>(); leftPortCount = 0; rightPortCount = 0; bottomPortCount = 0; inputLinksHash = new Hashtable<String, ArrayList<Link>>(); inputLinks = new ArrayList<Link>(); outputLinksHash = new Hashtable<String, ArrayList<Link>>(); outputLinks = new ArrayList<Link>(); inputportTerminals = new ArrayList<String>(); outputPortTerminals = new ArrayList<String>(); watcherTerminals = new HashMap(); newInstance = true; validityStatus = ValidityStatus.WARN.name(); componentName = DynamicClassProcessor.INSTANCE.getClazzName(this .getClass()); componentLabel = new ComponentLabel(componentName); componentLabelMargin = 16; prefix = XMLConfigUtil.INSTANCE.getComponent(componentName) .getDefaultNamePrefix(); defaultPrefix=XMLConfigUtil.INSTANCE.getComponent(componentName) .getDefaultNamePrefix(); initPortSettings(); toolTipErrorMessages = new LinkedHashMap<>(); status = ComponentExecutionStatus.BLANK; }
/** * Set the Size of this shape. Will not modify the size if newSize is null. * * @param newSize * a non-null Dimension instance or null */ public void setSize(Dimension newSize) { if(newSize.height<80) newSize.height=80; if (newSize != null) { size.setSize(newSize); firePropertyChange(Props.SIZE_PROP.getValue(), null, size); } }
/** * Instantiates a new CommentBox. * * @param compLabel * the comp label */ public CommentBox(String compLabel){ size = new Dimension(300, 60); this.text = compLabel; newInstance = true; if(count>0){ location = new Point(getLocation().x+count*10, getLocation().y+count*10); } }
/** * Sets the size. * * @param d * the new size */ public void setSize(Dimension d){ if (size.equals(d)) return; size = d; firePropertyChange("Size", null, size); }
/** * Sets the text of the TextFlow to the given value. * * @param newText * the new text value. */ public void setText(String newText) { textFlow.setText(newText); Dimension lineDimensions = TextUtilities.INSTANCE.getStringExtents(textFlow.getText(), getFont()); if(lineDimensions.width >= ELTFigureConstants.compLabelOneLineLengthLimitForText) { getBounds().setSize(ELTFigureConstants.compLabelOneLineLengthLimitForText, ELTFigureConstants.componentTwoLineLabelMargin); }else if(lineDimensions.width < ELTFigureConstants.compLabelOneLineLengthLimitForText){ getBounds().setSize(ELTFigureConstants.compLabelOneLineLengthLimitForText, ELTFigureConstants.componentOneLineLabelMargin); } }
/** * Creates a new CommentBoxFigure with a default MarginBorder size of DEFAULT_CORNER_SIZE - 3 and a FlowPage * containing a TextFlow with the style WORD_WRAP_SOFT. */ public CommentBoxFigure() { this(BentCornerFigure.DEFAULT_CORNER_SIZE - 3); setInitialColor(); defaultCommentBoxSize = new Dimension(300, 60); addCommentBoxListener(); }
private void setPortDimension() { if(PortAlignmentEnum.LEFT.equals(portAlignment)){ getBounds().setSize(new Dimension(27,10)); } else if(PortAlignmentEnum.RIGHT.equals(portAlignment)){ getBounds().setSize(new Dimension(27,10)); } else if(PortAlignmentEnum.BOTTOM.equals(portAlignment)){ getBounds().setSize(new Dimension(24,16)); } }
private void setInPortsCountDynamically(){ int prevInPortCount = getCastedModel().getInPortCount(); int outPortCount = 0, newInPortCount = 0; if (getCastedModel().getProperties().get("inPortCount") != null) { newInPortCount = Integer.parseInt((String.valueOf(getCastedModel().getProperties().get("inPortCount")))); } if (getCastedModel().getProperties().get("outPortCount") != null) { outPortCount = Integer.parseInt(String.valueOf(getCastedModel().getProperties().get("outPortCount"))); } if(prevInPortCount != newInPortCount){ int inPortCountToBeApplied = newInPortCount!=prevInPortCount ? newInPortCount : prevInPortCount; ComponentFigure compFig = (ComponentFigure)getFigure(); compFig.setHeight(inPortCountToBeApplied, outPortCount); Dimension newSize = new Dimension(compFig.getWidth(), compFig.getHeight()+getCastedModel().getComponentLabelMargin()); getCastedModel().setSize(newSize); refresh(); if(prevInPortCount < newInPortCount){ //Increment the ports getCastedModel().changeInPortCount(newInPortCount); adjustExistingPorts(); getCastedModel().incrementLeftSidePorts(newInPortCount, prevInPortCount); }else{ //decrement the ports List<String> portsToBeRemoved = populateInPortsToBeRemoved(prevInPortCount, newInPortCount); getCastedModel().decrementPorts(portsToBeRemoved); compFig.decrementAnchors(portsToBeRemoved); getCastedModel().changeInPortCount(newInPortCount); } } }
private void setUnusedPortsCountDynamically(){ int prevUnusedportCount = getCastedModel().getUnusedPortCount(); int newUnunsedPortCount=0; if(getCastedModel().getProperties().get("unusedPortCount")!=null) { newUnunsedPortCount=Integer.parseInt((String)getCastedModel().getProperties().get("unusedPortCount")); } if(prevUnusedportCount != newUnunsedPortCount){ int unusedPortCountToBeApplied = newUnunsedPortCount!=prevUnusedportCount ? newUnunsedPortCount : prevUnusedportCount; ComponentFigure compFig = (ComponentFigure)getFigure(); compFig.setWidth(unusedPortCountToBeApplied); Dimension newSize = new Dimension(compFig.getWidth(), compFig.getHeight()+getCastedModel().getComponentLabelMargin()); getCastedModel().setSize(newSize); refresh(); if(prevUnusedportCount < newUnunsedPortCount){ //Increment the ports getCastedModel().changeUnusedPortCount(newUnunsedPortCount); adjustExistingPorts(); getCastedModel().incrementBottomSidePorts(newUnunsedPortCount, prevUnusedportCount); }else{ //decrement the ports List<String> portsToBeRemoved = populateUnusedPortsToBeRemoved(prevUnusedportCount, newUnunsedPortCount); getCastedModel().decrementPorts(portsToBeRemoved); compFig.decrementAnchors(portsToBeRemoved); getCastedModel().changeUnusedPortCount(newUnunsedPortCount); } } }
@Override protected IFigure createFigure() { CommentBoxFigure label = new CommentBoxFigure(); Point loc = getLabel().getLocation(); Dimension size = getLabel().getSize(); Rectangle r = new Rectangle(loc, size); label.setBounds(r); if (label.getSize() != getLabel().getSize()) { label.setSize(getLabel().getSize()); } return label; }
@Override public void propertyChange(PropertyChangeEvent evt) { String prop = evt.getPropertyName(); if (StringUtils.equalsIgnoreCase(prop, LABEL_CONTENTS)) { refreshVisuals(); } else if (StringUtils.equalsIgnoreCase(prop, SIZE) || StringUtils.equalsIgnoreCase(prop, LOCATION)) { Point loc = getLabel().getLocation(); Dimension size = getLabel().getSize(); Rectangle r = new Rectangle(loc, size); ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), r); refreshVisuals(); } }
@Override public void execute() { component.setLocation(bounds.getLocation()); Dimension size = bounds.getSize(); if (size.width > 0 && size.height > 0) component.setSize(size); redo(); }
/** * Creating command for comment box */ private Command createCommentBoxCommand(){ ELTGraphicalEditor editor = (ELTGraphicalEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if(editor != null){ Container container = editor.getContainer(); org.eclipse.draw2d.geometry.Point point = editor.location; CommentBox label = new CommentBox(LABEL); label.setSize(new Dimension(300, 60)); label.setLocation(point); CommentBoxCommand command = new CommentBoxCommand(label,LABEL,container); return command; } return null; }
public void relocate(IFigure figure) { Dimension minimum = FigureUtilities.getTextExtents(text, figure.getFont()); figure.setSize(minimum); Point location = polyline.getPoints().getMidpoint(); Point offsetCopy = offset.getCopy(); offsetCopy.translate(location); figure.setLocation(offsetCopy); }
public void adjustConstraints() { int size = getColumns().size(); Rectangle r = getConstraints().getCopy(); Point point = r.getLocation(); Dimension dimension = r.getSize(); setConstraints(new Rectangle(point, new Dimension(dimension.width(), size >= 5 ? size * (i + 3) + 5 : h))); }
public Dimension getMatrixDimension() { if(!isMatrix()) throw new IllegalStateException("not a matrix"); try { return new Dimension(getLength() == 0 ? 0 : ((IJavaArray) elements[0]).getLength(), getLength()); } catch (DebugException e) { e.printStackTrace(); getRuntimeModel().setTerminated(); } return new Dimension(0, 0); }
void saveToImageFile() { Dimension size = rootFig.getPreferredSize(); Image image = new Image(Display.getDefault(), size.width, size.height); GC gc = new GC(image); SWTGraphics graphics = new SWTGraphics(gc); rootFig.paint(graphics); Clipboard clipboard = new Clipboard(Display.getDefault()); clipboard.setContents(new Object[]{image.getImageData()}, new Transfer[]{ ImageTransfer.getInstance()}); image.dispose(); gc.dispose(); }