Esempio n. 1
0
  @Override
  public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y) {

    java.awt.Graphics2D g2 = (java.awt.Graphics2D) g;
    g2.setRenderingHint(
        java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
    java.awt.geom.AffineTransform prevTransform = g2.getTransform();

    // g.setColor( java.awt.Color.BLUE );
    // g.fillRect( x, y, this.getIconWidth(), this.getIconHeight() );

    int typePlusBonusWidth = this.getIconWidth();
    if (this.isIndentForDepthAndMemberCountTextDesired) {
      int depth = org.lgna.project.ast.StaticAnalysisUtilities.getUserTypeDepth(type);
      if (depth > 0) {
        int dx = depth * INDENT_PER_DEPTH;
        g2.translate(dx, 0);
        typePlusBonusWidth -= dx;
        typePlusBonusWidth -= BONUS_GAP;
      }
    }

    int w = this.getBorderWidth();
    int h = this.getBorderHeight();

    // g.setColor( java.awt.Color.GREEN );
    // g.fillRect( x, y, typePlusBonusWidth, this.getIconHeight() );

    // g.setColor( java.awt.Color.RED );
    // g.fillRect( x, y, w, h );
    this.border.paintBorder(c, g, x, y, w, h);
    g.setColor(this.getTextColor(c));

    java.awt.Font prevFont = g.getFont();
    g.setFont(this.getTypeFont());
    edu.cmu.cs.dennisc.java.awt.GraphicsUtilities.drawCenteredText(
        g, this.getTypeText(), x, y, w, h);

    if (this.isIndentForDepthAndMemberCountTextDesired) {
      if (this.bonusFont != null) {
        g.setFont(this.bonusFont);
        edu.cmu.cs.dennisc.java.awt.GraphicsUtilities.drawCenteredText(
            g, this.getBonusText(), x + w + BONUS_GAP, y, typePlusBonusWidth - w, h);
      }
    }
    g.setFont(prevFont);
    g2.setTransform(prevTransform);
  }
Esempio n. 2
0
 @Override
 public int getIconWidth() {
   int rv = this.getBorderWidth();
   if (this.isIndentForDepthAndMemberCountTextDesired) {
     int depth = org.lgna.project.ast.StaticAnalysisUtilities.getUserTypeDepth(type);
     if (depth > 0) {
       rv += (depth * INDENT_PER_DEPTH);
     }
   }
   if (this.isIndentForDepthAndMemberCountTextDesired) {
     rv += BONUS_GAP;
     java.awt.geom.Rectangle2D bonusTextBounds = this.getBonusTextBounds();
     rv += (int) bonusTextBounds.getWidth();
   }
   return rv;
 }