Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package tools.tracesviewer;
  
  import java.awt.*;
  
  public class StraightArrow extends Arrow {
  
      public Dimension dimensionInfo;
  
      public StraightArrow(
         boolean selected,
         String arrowName,
         int xmin,
         int xmax,
         int ymin,
         int ymax,
         boolean flag,
         boolean info) {
         super(selectedarrowNameflagxminxmaxyminymaxinfo);
 
     }
 
     public int xmin() {
         return Math.min();
     }
 
     public int xmax() {
         return Math.max();
     }
 
     public int ymin() {
         return Math.min();
     }
 
     public int ymax() {
         return Math.max();
     }
 
     public void draw(Graphics g) {
         // Set the color of this arrow:
         if ()
             g.setColor(.);
         else
             g.setColor();
 
         Font font = g.getFont();
         Font newFont = new Font(font.getName(), . | ., 14);
         g.setFont(newFont);
 
         int y = ( + ) / 2;
         if (.getStatusInfo() != null)
             if (.getStatusInfo().indexOf("Dropped") == -1) {
                 g.drawLine(yy);
                 g.drawLine(
                     Math.min() + 2,
                     y - 1,
                     Math.max() - 2,
                     y - 1);
                 g.drawLine(
                     Math.min() + 2,
                     y + 1,
                     Math.max() - 2,
                     y + 1);
 
             } else {
 
                 if ( < ) {
                     int x = ;
                     while ((x + 8) < ) {
                         g.drawLine(xyx + 8, y);
                         g.drawLine(xy - 1, x + 8, y - 1);
                         g.drawLine(xy + 1, x + 8, y + 1);
                         x += 16;
                     }
 
                 } else {
                     int x = ;
                     while ((x - 8) > ) {
                         g.drawLine(xyx - 8, y);
                         g.drawLine(xy - 1, x - 8, y - 1);
                         g.drawLine(xy + 1, x - 8, y + 1);
                         x -= 16;
                     }
 
                 }
 
             }
         else {
             g.drawLine(yy);
             g.drawLine(
                 Math.min() + 2,
                 y - 1,
                 Math.max() - 2,
                 y - 1);
             g.drawLine(
                 Math.min() + 2,
                 y + 1,
                 Math.max() - 2,
                 y + 1);
 
        }
        String timeString = "Time : " + .getTime() + " ms";
        int timeStringWidth =
            g.getFontMetrics(g.getFont()).stringWidth(timeString);
        int fistLineStringWidth =
            g.getFontMetrics(g.getFont()).stringWidth(
                .getFirstLine());
        if ( > ) {
            g.drawString(
                .getFirstLine(),
                
                    + . / 2
                    - fistLineStringWidth / 2,
                y - 5);
            g.drawString(
                timeString,
                 + . / 2 - timeStringWidth / 2,
                y + g.getFontMetrics(g.getFont()).getHeight());
            g.drawLine(y - 10, y - 5);
            g.drawLine( - 1, y - 11, y - 5);
            g.drawLine( - 2, y - 12, y - 5);
            g.drawLine(y - 10, y + 5);
            g.drawLine( - 1, y - 11, y + 5);
            g.drawLine( - 2, y - 12, y + 5);
        } else {
            g.drawString(
                .getFirstLine(),
                
                    + . / 2
                    - fistLineStringWidth / 2,
                y - 2);
            g.drawString(
                timeString,
                 + . / 2 - timeStringWidth / 2,
                y + 2 + g.getFontMetrics(g.getFont()).getHeight());
            g.drawLine(y + 10, y + 5);
            g.drawLine( + 1, y + 11, y + 5);
            g.drawLine( + 2, y + 12, y + 5);
            g.drawLine(y + 10, y - 5);
            g.drawLine( + 1, y + 11, y - 5);
            g.drawLine( + 2, y + 12, y - 5);
        } // else
        // draw the info sign if needed
        if () {
            //System.out.println("Display info sign ready");
            String statusString = .getStatusInfo();
            if (statusString == null || statusString.trim().equals("")) {
                //  System.out.println("No information: problem for displaying the info sign");
            } else {
                //g.setColor(new Color(0,0,125)) ;
                g.setColor(.);
                //g.fillOval(xmax() - 20 , y - 20 , 15, 15) ;
                 = xmax() - 25;
                 = xmax();
                 = y - 30;
                 = y - 3;
                //x, y, width, height
                g.fillOval(xmax() - 25, y - 25, 20, 20);
                //g.setColor(Color.black) ;
                //g.drawOval(xmax() - 20 , y - 20 , 15, 15) ;
                g.setColor(.);
                Font f = g.getFont();
                g.setFont(
                    new Font(
                        f.getName(),
                        . | .,
                        f.getSize()));
                g.drawString("i"xmax() - 17, y - 11);
                g.setFont(f);
            }
        }
        if () {
            //System.out.println("Display info ready");
            String statusString = .getStatusInfo();
            if (statusString == null || statusString.trim().equals("")) {
                //   System.out.println("No information: problem for displaying info");
            } else {
                Font f = g.getFont();
                g.setFont(
                    new Font(
                        f.getName(),
                        . | .,
                        f.getSize()));
                int statusStringWidth =
                    g.getFontMetrics(g.getFont()).stringWidth(statusString);
                int statusStringHeight =
                    g.getFontMetrics(g.getFont()).getHeight();
                int boxWidth =
                    Math.max(
                        .,
                        statusStringWidth + 10);
                // shadow
                g.setColor(.);
                g.fillRoundRect(
                    xmin() + 15,
                    y - . / 2 + 15,
                    boxWidth,
                    .,
                    10,
                    10);
                // box
                g.setColor(.);
                g.fillRoundRect(
                    xmin() + 10,
                    y - . / 2 + 10,
                    boxWidth,
                    .,
                    10,
                    10);
                // thick border
                g.setColor(.);
                g.drawRoundRect(
                    xmin() + 10,
                    y - . / 2 + 10,
                    boxWidth,
                    .,
                    10,
                    10);
                g.drawRoundRect(
                    xmin() + 11,
                    y - . / 2 + 11,
                    boxWidth - 2,
                    .,
                    9,
                    9);
                // info string
                g.setColor(.);
                if (boxWidth == .)
                    g.drawString(
                        statusString,
                        xmin()
                            + 10
                            + 2
                            + . / 2
                            - statusStringWidth / 2,
                        y + 10 + statusStringHeight / 2);
                else
                    g.drawString(
                        statusString,
                        xmin() + 10 + 5,
                        y + 10 + statusStringHeight / 2);
            }
        }
        if () {
            //System.out.println("Display Tip tool ready");
            Font f = g.getFont();
            g.setFont(
                new Font(
                    f.getName(),
                    . | .,
                    f.getSize() - 2));
            String text;
            if ()
                text =
                    "Left click to select the message, Right click to display generated event.";
            else
                text = "Left click to select the message";
            int textWidth = g.getFontMetrics(g.getFont()).stringWidth(text);
            int textHeight = g.getFontMetrics(g.getFont()).getHeight();
            if ( < ) {
                // x,y,width,height
                // shadow
                g.setColor(.);
                g.fillRoundRect(
                    xmin() - 47,
                    y + 21,
                    textWidth + 5,
                    textHeight + 2,
                    10,
                    10);
                // box
                g.setColor(.);
                g.fillRoundRect(
                    xmin() - 50,
                    y + 21,
                    textWidth + 4,
                    textHeight - 2,
                    10,
                    10);
                // thick border
                g.setColor(.);
                g.drawRoundRect(
                    xmin() - 50,
                    y + 21,
                    textWidth + 5,
                    textHeight - 3,
                    10,
                    10);
                g.drawRoundRect(
                    xmin() - 50,
                    y + 21,
                    textWidth + 5,
                    textHeight - 3,
                    9,
                    9);
                // String, x,y
                g.setColor(.);
                g.drawString(text - 46, y + 16 + textHeight);
            } else {
                // shadow
                g.setColor(.);
                g.fillRoundRect(
                    xmin() - 47,
                    y + 21,
                    textWidth + 5,
                    textHeight + 2,
                    10,
                    10);
                // box
                g.setColor(.);
                g.fillRoundRect(
                    xmin() - 50,
                    y + 21,
                    textWidth + 4,
                    textHeight - 2,
                    10,
                    10);
                // thick border
                g.setColor(.);
                g.drawRoundRect(
                    xmin() - 50,
                    y + 21,
                    textWidth + 5,
                    textHeight - 3,
                    10,
                    10);
                g.drawRoundRect(
                    xmin() - 50,
                    y + 21,
                    textWidth + 5,
                    textHeight - 3,
                    9,
                    9);
                // String, x,y
                g.setColor(.);
                g.drawString(textxmin() - 46, y + 16 + textHeight);
            }
        }
    }
New to GrepCode? Check out our FAQ X