Package simtools.shapes

Examples of simtools.shapes.AbstractShape


          CompoundEdit ce=new CompoundEdit();
          boolean ok=false;
          for(int i=0;i<v.size();i++){
            Object o=v.get(i);
            if(o instanceof AbstractShape){
              AbstractShape as=(AbstractShape)o;
              if(as.setProperties(DiagramSelectionPropertiesPanel.this, ce)){
                ok=true;
              }
            }
          }
          if(ok){
View Full Code Here


        try {
          io = new ObjectInputStream(bi);
          svg=(ShapesContainer)io.readObject();
          editor.addComponent(svg.getComponent());
          for (Iterator it = svg.iterator(); it.hasNext();) {
            AbstractShape abs = (AbstractShape)it.next();
            abs.addListener( (ShapeListener)svg.getComponent());
          }
             
        } catch (IOException e1) {
          e1.printStackTrace();
        } catch (ClassNotFoundException e2) {
View Full Code Here

    /* (non-Javadoc)
     * @see jsynoptic.base.Plugin#createShape(java.lang.String)
     */
    public AbstractShape createShape(String name) {
        AbstractShape res = null;

        if (name.equals(CIRCUIT_CONNECTOR)) {
            res = createShape(name, 0, 0, 100, 0);

        } else   if (name.equals(EMITTER)) {
View Full Code Here

        return res;
    }
   
    public AbstractShape createShape(String name, int x, int y, int width, int height) {
        AbstractShape res = null;

        if (name.equals(CIRCUIT_CONNECTOR)) {
            res = new CircuitConnection(x, y, width, height);

        } else   if (name.equals(EMITTER)) {
View Full Code Here

  /* (non-Javadoc)
   * @see jsynoptic.base.Plugin#createShape(java.lang.String)
   */
  public AbstractShape createShape(String name) {
      AbstractShape res = null;

      if (name.equals(SVG_SHAPE)){
          res =  createSvgShape();
      }
      return res;
View Full Code Here

    /* (non-Javadoc)
     * @see jsynoptic.base.Plugin#createShape(java.lang.String)
     */
    public AbstractShape createShape(String name) {
        AbstractShape res = null;

        if (name.equals(TIME_PLOT)){
            res =  createTimePlot();
        }
        return res;
View Full Code Here

    }

    protected void restoreAbsoluteLinks(ShapesContainer sc, File f) throws IOException{
        for (Iterator it = sc.iterator(); it.hasNext();) {
            try {
                AbstractShape abs = (AbstractShape) it.next();
                abs.addListener( (ShapeListener)sc.getComponent());
                if (!(abs instanceof Linkable)) {
                    continue;
                }
                Linkable l = (Linkable) abs;
                // Now trying to restore absolute file
View Full Code Here

    protected void setShapesProperties(){

        // Get properties that have changed
        List changedProperties = new ArrayList();

        AbstractShape shapeReference = (AbstractShape)shapes.get(0);
        String[] contentsProperties = content.getPropertyNames();

        for(int i=0; i < contentsProperties.length; i++){
            Object newValue =  content.getPropertyValue(contentsProperties[i]);
            Object refValue = shapeReference.getPropertyValue(contentsProperties[i]);

            if ( ( (newValue == null) && (refValue != null))
                    ||  ( (newValue != null) && (refValue == null))
                    || ( newValue!=null && refValue != null && !newValue.equals(refValue))
            ){
                changedProperties.add(contentsProperties[i]);
            }
        }

        // If some properties have changed, apply them to all shapes

        if (!changedProperties.isEmpty()){
            CompoundEdit shapesEdit = new CompoundEdit();

            for(int i=0;i<shapes.size(); i++){
                AbstractShape shape = (AbstractShape)shapes.get(i);

                // Merge the changes with all shape properties before
                ChangedProperties shapeProperties = new ChangedProperties();
                String[] shapePropertiesName = shape.getPropertyNames();

                for(int j=0; j < shapePropertiesName.length; j++){
                    String property = shapePropertiesName[j];

                    if (changedProperties.contains(property)){
                        shapeProperties.setPropertyValue(property, content.getPropertyValue(property));

                    } else {
                        shapeProperties.setPropertyValue(property, shape.getPropertyValue(property));
                    }
                }

                CompoundEdit ce = new CompoundEdit();
                if (shape.setProperties(shapeProperties, ce)) {
                    shapesEdit.addEdit(ce);  
                }  
                ce.end();
            }
View Full Code Here

      int x=(int)((double)pt.x/_param.scale)-_param.xmargin;
      int y=(int)((double)pt.y/_param.scale)-_param.ymargin;
      Vector v=DiagramClipboard.get();
      if(v.size()>0){
        if(v.get(0) instanceof AbstractShape){
          AbstractShape as=(AbstractShape)v.get(0);
          as.translate(x,y);
          ShapesContainer.this.addElement(as);
        }
      }
      DiagramClipboard.get().clear();
      _dragging=false;
View Full Code Here

        for(int cellRow=0; cellRow < nbRows; cellRow++){
            for(int cellColumn=0; cellColumn < nbColumns; cellColumn++) {
                int cellOx =  cellColumn*(cellWidth + colMargin) + BORDER_X_MARGIN;
                int cellOy =  cellRow*(cellHeight + rowMargin) + cellHeight + BORDER_Y_MARGIN;

                AbstractShape newShape =  createShape(cellOx, cellOy, width, height);

                // Resize the shape size
                if (newShape instanceof Resizable){
                    //the current size is withdrawn and the new size is added
                    ((Resizable)newShape).resize(((-newShape.getBounds().width)+ cellWidth),((-newShape.getBounds().height)+ cellHeight));
                }
                sc.addElement(newShape);
            }
        }
    }
View Full Code Here

TOP

Related Classes of simtools.shapes.AbstractShape

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.