Package java.awt

Examples of java.awt.Shape


        int hCenter = 0;

        Rectangle bounds;

        for(int i=0; i<_selectedElements.size(); i++) {
            Shape s = ((ElementSelection)_selectedElements.get(i)).getShape();
            bounds = s.getBounds();
            hCenter += bounds.x + bounds.width/2;
        }
        hCenter /= _selectedElements.size();

        CompoundEdit ce = new CompoundEdit();
View Full Code Here


        meanDistance/=selection.size()-1;

        // Trnaslate shapes
        CompoundEdit ce = new CompoundEdit();

        Shape shape, previousShape;
        for(int i=1; i<selection.size(); i++) {
            ElementSelection ss = ((ElementSelection)selection.get(i));
            shape = ss.getShape();
            previousShape= ((ElementSelection)selection.get(i-1)).getShape();
            int dx = previousShape.getBounds().x + previousShape.getBounds().width + meanDistance  - shape.getBounds().x;

            ss.translateShape(dx,0);
            if(ce!=null){
                ce.addEdit(ss.translateShapeEnd());
            }
View Full Code Here

        }
        meanDistance/=selection.size()-1;

        // Translate shapes
        CompoundEdit ce = new CompoundEdit();
        Shape shape, previousShape;
        for(int i=1; i<selection.size(); i++) {
            ElementSelection ss = ((ElementSelection)selection.get(i));
            shape = ss.getShape();
            previousShape= ((ElementSelection)selection.get(i-1)).getShape();

            int dy = previousShape.getBounds().y + previousShape.getBounds().height + meanDistance  - shape.getBounds().y;

            ss.translateShape(0, dy);
            if(ce!=null){
                ce.addEdit(ss.translateShapeEnd());
            }
View Full Code Here

     * @param ox
     * @param oy
     * @return the first shape found at given position
     */
    public Shape getShapeAt(int ox, int oy){
        Shape res = null;

        if(getElementContainer() != null){
            for(int i=0; i<getElementContainer().size() && res==null;i++){
                Shape s = (Shape)getElementContainer().get(i);
                if( !(s instanceof Connection) && s.contains(ox,oy)){
                    res = s;
                }
            }
        }
        return res;
View Full Code Here

    public Connection getConnectionAt(int ox, int oy){
        Connection res = null;

        if(getElementContainer() != null){
            for(int i=0; i<getElementContainer().size() && res==null;i++){
                Shape s = (Shape)getElementContainer().get(i);
                if((s instanceof Connection) && s.contains(ox,oy)){
                    res = (Connection)s;
                }
            }
        }
        return res;
View Full Code Here

        fireUndoableEditUpdate(new UndoableEditEvent(this, compoundEdit));
    }
   
    public Shape getShapeAt(int ox, int oy){
      for(int i=(ShapesContainer.this.size()-1); i>=0; i--){
        Shape s=(Shape)elementAt(i);
        if(s.contains(ox,oy)){
          return s;
        }
      }
      return null;
    }
View Full Code Here

        AffineTransform affineTransform = new AffineTransform();
        affineTransform.setToTranslation(slopeEndposX, slopeEndposY);
        affineTransform.rotate(theta);
        Polygon first = new Polygon(new int[] {-5,0,-5},new int[] {2,0,-2},3);
        Shape firstArrow = affineTransform.createTransformedShape(first);
        g2.fill(firstArrow);
        g2.draw(firstArrow);

        // Restore old preferences
        g2.setColor(oldColor);
View Full Code Here

        protected abstract void resize(int dx, int dy);

        protected abstract void updateConnector();
       
        public void draw(Graphics2D g){
            Shape s = getShape();
            if (s != null){
                Color oldColor = g.getColor();
                g.setColor(connectionSignal!= null? connectionSignal.getColor() : drawColor);
                g.draw(s);
                g.setColor(oldColor);
View Full Code Here

     * @see simtools.shapes.ShapesContainer.ShapesComponent#drawBounds(java.awt.Graphics2D, simtools.diagram.ShapeSelection)
     */
    protected void drawBounds(Graphics2D g2, ElementSelection selection) {
      Color c = g2.getColor();
     
      Shape shape = selection.getShape();
     
      if (shape instanceof Linkable) {
        String link = ((Linkable)shape).getLink();
        if ((link!=null) && (!link.equals(""))) {
          JSynoptic.setStatus(messageWriter.print1args("followLink",link));
View Full Code Here

        double selY=((double)e.getY()/_param.scale)-_param.ymargin;
       
        for (int i=ShapesContainer.this.size()-1;i>=0; i--) { // outer Vector API
          Object o = get(i);
          if (! (o instanceof Shape)) continue;
          Shape s=(Shape)o;
          if (s.contains(selX,selY)) {
            if((getElementContainer().getSelection().getShapeCount()!=1) || !getElementContainer().getSelection().isSelected(s)){
              getElementContainer().getSelection().selectPoint((int)selX,(int)selY);
              repaint();
              if(getElementContainer().getSelection().getSelectedShape(s)==null){
                continue; // should not occur but ...
View Full Code Here

TOP

Related Classes of java.awt.Shape

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.