public void drawShape(int x,int y,int w,int h,Map<String,Object> style){
  Color penColor=mxUtils.getColor(style,mxConstants.STYLE_STROKECOLOR);
  float penWidth=mxUtils.getFloat(style,mxConstants.STYLE_STROKEWIDTH,1);
  int pw=(int)Math.ceil(penWidth * scale);
  if (g.hitClip(x - pw,y - pw,w + 2 * pw,h + 2 * pw)) {
    boolean shadow=mxUtils.isTrue(style,mxConstants.STYLE_SHADOW,false);
    Color fillColor=mxUtils.getStyleFillColor(style);
    Paint fillPaint=getFillPaint(new Rectangle(x,y,w,h),fillColor,style);
    if (penWidth > 0) {
      setStroke(penWidth,style);
    }
    String shape=mxUtils.getString(style,mxConstants.STYLE_SHAPE,"");
    if (shape.equals(mxConstants.SHAPE_IMAGE)) {
      String img=getImageForStyle(style);
      if (img != null) {
        drawImage(x,y,w,h,img);
      }
    }
 else     if (shape.equals(mxConstants.SHAPE_LINE)) {
      if (penColor != null) {
        g.setColor(penColor);
        String direction=mxUtils.getString(style,mxConstants.STYLE_DIRECTION,mxConstants.DIRECTION_EAST);
        if (direction.equals(mxConstants.DIRECTION_EAST) || direction.equals(mxConstants.DIRECTION_WEST)) {
          int mid=(int)(y + h / 2);
          drawLine(x,mid,x + w,mid);
        }
 else {
          int mid=(int)(x + w / 2);
          drawLine(mid,y,mid,y + h);
        }
      }
    }
 else     if (shape.equals(mxConstants.SHAPE_ELLIPSE)) {
      drawOval(x,y,w,h,fillColor,fillPaint,penColor,shadow);
    }
 else     if (shape.equals(mxConstants.SHAPE_DOUBLE_ELLIPSE)) {
      drawOval(x,y,w,h,fillColor,fillPaint,penColor,shadow);
      int inset=(int)((3 + penWidth) * scale);
      x+=inset;
      y+=inset;
      w-=2 * inset;
      h-=2 * inset;
      drawOval(x,y,w,h,null,null,penColor,false);
    }
 else     if (shape.equals(mxConstants.SHAPE_RHOMBUS)) {
      drawRhombus(x,y,w,h,fillColor,fillPaint,penColor,shadow);
    }
 else     if (shape.equals(mxConstants.SHAPE_CYLINDER)) {
      drawCylinder(x,y,w,h,fillColor,fillPaint,penColor,shadow);
    }
 else     if (shape.equals(mxConstants.SHAPE_ACTOR)) {
      drawActor(x,y,w,h,fillColor,fillPaint,penColor,shadow);
    }
 else     if (shape.equals(mxConstants.SHAPE_CLOUD)) {
      drawCloud(x,y,w,h,fillColor,fillPaint,penColor,shadow);
    }
 else     if (shape.equals(mxConstants.SHAPE_TRIANGLE)) {
      String direction=mxUtils.getString(style,mxConstants.STYLE_DIRECTION,"");
      drawTriangle(x,y,w,h,fillColor,fillPaint,penColor,shadow,direction);
    }
 else     if (shape.equals(mxConstants.SHAPE_HEXAGON)) {
      String direction=mxUtils.getString(style,mxConstants.STYLE_DIRECTION,"");
      drawHexagon(x,y,w,h,fillColor,fillPaint,penColor,shadow,direction);
    }
 else {
      drawRect(x,y,w,h,fillColor,fillPaint,penColor,shadow,mxUtils.isTrue(style,mxConstants.STYLE_ROUNDED));
      if (shape.equals(mxConstants.SHAPE_LABEL)) {
        String img=getImageForStyle(style);
        if (img != null) {
          String imgAlign=mxUtils.getString(style,mxConstants.STYLE_IMAGE_ALIGN,mxConstants.ALIGN_CENTER);
          String imgValign=mxUtils.getString(style,mxConstants.STYLE_IMAGE_VERTICAL_ALIGN,mxConstants.ALIGN_MIDDLE);
          int imgWidth=(int)(mxUtils.getInt(style,mxConstants.STYLE_IMAGE_WIDTH,mxConstants.DEFAULT_IMAGESIZE) * scale);
          int imgHeight=(int)(mxUtils.getInt(style,mxConstants.STYLE_IMAGE_HEIGHT,mxConstants.DEFAULT_IMAGESIZE) * scale);
          int spacing=(int)(mxUtils.getInt(style,mxConstants.STYLE_SPACING,2) * scale);
          int imgX=x;
          if (imgAlign.equals(mxConstants.ALIGN_LEFT)) {
            imgX+=spacing;
          }
 else           if (imgAlign.equals(mxConstants.ALIGN_RIGHT)) {
            imgX+=w - imgWidth - spacing;
          }
 else {
            imgX+=(w - imgWidth) / 2;
          }
          int imgY=y;
          if (imgValign.equals(mxConstants.ALIGN_TOP)) {
            imgY+=spacing;
          }
 else           if (imgValign.equals(mxConstants.ALIGN_BOTTOM)) {
            imgY+=h - imgHeight - spacing;
          }
 else {
            imgY+=(h - imgHeight) / 2;
          }
          drawImage(imgX,imgY,imgWidth,imgHeight,img);
        }
      }
    }
  }
}

public void drawShape ( int x , int y , int w , int h , Map < String , Object > style ) { Color penColor = mxUtils . getColor ( style , mxConstants . STYLE_STROKECOLOR ) ; float penWidth = mxUtils . getFloat ( style , mxConstants . STYLE_STROKEWIDTH , 1 ) ; int pw = ( int ) Math . ceil ( penWidth * scale ) ; if ( g . hitClip ( x - pw , y - pw , w + 2 * pw , h + 2 * pw ) ) { boolean shadow = mxUtils . isTrue ( style , mxConstants . STYLE_SHADOW , false ) ; Color fillColor = mxUtils . getStyleFillColor ( style ) ; Paint fillPaint = getFillPaint ( new Rectangle ( x , y , w , h ) , fillColor , style ) ; if ( penWidth > 0 ) { setStroke ( penWidth , style ) ; } String shape = mxUtils . getString ( style , mxConstants . STYLE_SHAPE , "" ) ; if ( shape . equals ( mxConstants . SHAPE_IMAGE ) ) { String img = getImageForStyle ( style ) ; if ( img != null ) { drawImage ( x , y , w , h , img ) ; } } else if ( shape . equals ( mxConstants . SHAPE_LINE ) ) { if ( penColor != null ) { g . setColor ( penColor ) ; String direction = mxUtils . getString ( style , mxConstants . STYLE_DIRECTION , mxConstants . DIRECTION_EAST ) ; if ( direction . equals ( mxConstants . DIRECTION_EAST ) || direction . equals ( mxConstants . DIRECTION_WEST ) ) { int mid = ( int ) ( y + h / 2 ) ; drawLine ( x , mid , x + w , mid ) ; } else { int mid = ( int ) ( x + w / 2 ) ; drawLine ( mid , y , mid , y + h ) ; } } } else if ( shape . equals ( mxConstants . SHAPE_ELLIPSE ) ) { drawOval ( x , y , w , h , fillColor , fillPaint , penColor , shadow ) ; } else if ( shape . equals ( mxConstants . SHAPE_DOUBLE_ELLIPSE ) ) { drawOval ( x , y , w , h , fillColor , fillPaint , penColor , shadow ) ; int inset = ( int ) ( ( 3 + penWidth ) * scale ) ; x += inset ; y += inset ; w -= 2 * inset ; h -= 2 * inset ; drawOval ( x , y , w , h , null , null , penColor , false ) ; } else if ( shape . equals ( mxConstants . SHAPE_RHOMBUS ) ) { drawRhombus ( x , y , w , h , fillColor , fillPaint , penColor , shadow ) ; } else if ( shape . equals ( mxConstants . SHAPE_CYLINDER ) ) { drawCylinder ( x , y , w , h , fillColor , fillPaint , penColor , shadow ) ; } else if ( shape . equals ( mxConstants . SHAPE_ACTOR ) ) { drawActor ( x , y , w , h , fillColor , fillPaint , penColor , shadow ) ; } else if ( shape . equals ( mxConstants . SHAPE_CLOUD ) ) { drawCloud ( x , y , w , h , fillColor , fillPaint , penColor , shadow ) ; } else if ( shape . equals ( mxConstants . SHAPE_TRIANGLE ) ) { String direction = mxUtils . getString ( style , mxConstants . STYLE_DIRECTION , "" ) ; drawTriangle ( x , y , w , h , fillColor , fillPaint , penColor , shadow , direction ) ; } else if ( shape . equals ( mxConstants . SHAPE_HEXAGON ) ) { String direction = mxUtils . getString ( style , mxConstants . STYLE_DIRECTION , "" ) ; drawHexagon ( x , y , w , h , fillColor , fillPaint , penColor , shadow , direction ) ; } else { drawRect ( x , y , w , h , fillColor , fillPaint , penColor , shadow , mxUtils . isTrue ( style , mxConstants . STYLE_ROUNDED ) ) ; if ( shape . equals ( mxConstants . SHAPE_LABEL ) ) { String img = getImageForStyle ( style ) ; if ( img != null ) { String imgAlign = mxUtils . getString ( style , mxConstants . STYLE_IMAGE_ALIGN , mxConstants . ALIGN_CENTER ) ; String imgValign = mxUtils . getString ( style , mxConstants . STYLE_IMAGE_VERTICAL_ALIGN , mxConstants . ALIGN_MIDDLE ) ; int imgWidth = ( int ) ( mxUtils . getInt ( style , mxConstants . STYLE_IMAGE_WIDTH , mxConstants . DEFAULT_IMAGESIZE ) * scale ) ; int imgHeight = ( int ) ( mxUtils . getInt ( style , mxConstants . STYLE_IMAGE_HEIGHT , mxConstants . DEFAULT_IMAGESIZE ) * scale ) ; int spacing = ( int ) ( mxUtils . getInt ( style , mxConstants . STYLE_SPACING , 2 ) * scale ) ; int imgX = x ; if ( imgAlign . equals ( mxConstants . ALIGN_LEFT ) ) { imgX += spacing ; } else if ( imgAlign . equals ( mxConstants . ALIGN_RIGHT ) ) { imgX += w - imgWidth - spacing ; } else { imgX += ( w - imgWidth ) / 2 ; } int imgY = y ; if ( imgValign . equals ( mxConstants . ALIGN_TOP ) ) { imgY += spacing ; } else if ( imgValign . equals ( mxConstants . ALIGN_BOTTOM ) ) { imgY += h - imgHeight - spacing ; } else { imgY += ( h - imgHeight ) / 2 ; } drawImage ( imgX , imgY , imgWidth , imgHeight , img ) ; } } } } }
draws the shape specified with the style_shape key in the given style .
