예제 #1
0
  @Override
  public void paint(Graphics g) {
    super.paint(g);

    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(
        RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    int v = value;
    boolean is_ng = false;
    if (v > 999) v = 999;
    if (v < 0) {
      v *= -1;
      is_ng = true;
      if (v > 99) v = 99;
    }
    for (int i = 2, p = 1; i >= 0; i--, v /= 10) {
      BufferedImage r = GameResource.sevenSegmentDigits[v % 10];
      g2.drawImage(r, i * 15 + 5, 5, 15, 30, this);
    }
    if (is_ng) {
      BufferedImage r = GameResource.sevenSegmentDigits[10];
      g2.drawImage(r, 0 * 15 + 5, 5, 15, 30, this);
    }
  }
예제 #2
0
  @Override
  public final void paint(Graphics g) {

    super.paint(g);
    Graphics2D g2 = (Graphics2D) g;
    Composite old = g2.getComposite(); // Store non-transparent composite

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); // 40% transparency
    g2.drawRect(0, 0, getWidth() - 1, getHeight() - 1);

    Font drawFont = g2.getFont();
    g2.setFont(notificationFont);
    adaptDimensions();

    int textX = 5;
    int textY = (getHeight() / 2 + 3);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f)); // 70% transparency
    g2.drawString(message, textX, textY);

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f)); // 5% transparency
    g2.setColor(java.awt.Color.blue);
    g2.fillRect(0, 0, this.getWidth() - 1, this.getHeight() - 1);
    g2.setComposite(old);
    g2.setFont(drawFont);
  }
예제 #3
0
  @Override
  public void paint(Graphics g) {
    onResize();
    double speed = this.speed;
    float rotation = 0;
    Graphics2D g2d = (Graphics2D) g;

    drawBackground(g2d);

    // needle
    g2d.translate(getNeedleLocation().x, getNeedleLocation().y); // translate begin middle
    drawFrom00Center(g2d);
    g2d.rotate(getNeedleStartRotation()); // rotate begin needle
    rotation += getNeedleStartRotation();
    drawBackgroundWithNeedleStartRotation(g2d);

    g2d.rotate(step1Speed * speed); // rotate begin speed
    rotation += step1Speed * speed;

    drawNeedle(g2d);
    drawOnNeedleSpeedRotation(g2d);

    g2d.rotate(-rotation); // rotate end,rotate end
    g2d.translate(-getNeedleLocation().x, -getNeedleLocation().y); // //translate end
    rotation = 0;

    super.paint(g2d);
  }
  @Override
  public void paint(Graphics g) {
    super.paint(g);

    // test1(g);
    // test2(g);
    test3(g);
  }
예제 #5
0
 @Override
 public void paint(Graphics g) {
   if (isGLDrawing() && drawableComponent != null && canvas != null) {
     canvas.display();
   } else {
     super.paint(g);
   }
 }
예제 #6
0
 public void paint(Graphics g) {
   if (g instanceof Graphics2D) {
     Graphics2D g2 = (Graphics2D) g;
     g2.setRenderingHint(
         RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
     g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   }
   super.paint(g);
 }
  private BufferedImage exportImageFromComponent(JComponent component) {
    BufferedImage image =
        new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);
    Graphics gx = image.getGraphics();
    component.paint(gx);
    gx.dispose();

    return image;
  }
예제 #8
0
 public void paint(Graphics g) {
   if (comp != null) {
     width = comp.getWidth() / 6;
     height = comp.getHeight() * 2 / 3;
   }
   g.setColor(bgColor);
   g.fillRect(x, y, width, height);
   g.setColor(fgColor);
   g.setFont(font);
   g.drawString(strTray, x / 2 + width / 2, y + height + 10);
   super.paint(g);
 }
예제 #9
0
 /*
  *  Create a BufferedImage for Swing components.
  *  All or part of the component can be captured to an image.
  *
  *  @param	 component Swing component to create image from
  *  @param	 region The region of the component to be captured to an image
  *  @param	 fileName name of file to be created or null
  *  @return	image the image for the given region
  *  @exception IOException if an error occurs during writing
  */
 public static BufferedImage createImage(JComponent component, Rectangle region, String fileName)
     throws IOException {
   boolean opaqueValue = component.isOpaque();
   component.setOpaque(true);
   BufferedImage image =
       new BufferedImage(region.width, region.height, BufferedImage.TYPE_INT_RGB);
   Graphics2D g2d = image.createGraphics();
   g2d.setClip(region);
   component.paint(g2d);
   g2d.dispose();
   component.setOpaque(opaqueValue);
   ScreenCapture.writeImage(image, fileName);
   return image;
 }
예제 #10
0
  public void paint(Graphics g) {
    super.paint(g);
    if (thumbnail != null) {
      int x = getWidth() / 2 - thumbnail.getIconWidth() / 2;
      int y = getHeight() / 2 - thumbnail.getIconHeight() / 2;
      if (y < 0) {
        y = 0;
      }

      if (x < 5) {
        x = 5;
      }
      thumbnail.paintIcon(this, g, x, y);
    }
  }
예제 #11
0
 private void write(JComponent myComponent, OutputStream out) throws Exception {
   int imgWidth = (int) myComponent.getSize().getWidth(),
       imgHeight = (int) myComponent.getSize().getHeight();
   Dimension size = new Dimension(imgWidth, imgHeight);
   BufferedImage myImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics2D g2 = myImage.createGraphics();
   myComponent.paint(g2);
   try {
     JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
     encoder.encode(myImage);
     out.close();
   } catch (Exception e) {
     throw new Exception("GRAPHICS ERROR,CANNOT CREATE JPEG FORMAT");
   }
 }
예제 #12
0
 @Override
 public void paint(Graphics g) {
   // always paint background color; must happen before any controlPaint; extract to separate
   // method if override needed
   Graphics2D g2 = (Graphics2D) g;
   g2.setBackground(this.getBackground());
   RectAdp clipRect = GxwCore_lang.XtoRectAdp(g2.getClipBounds());
   g2.clearRect(clipRect.X(), clipRect.Y(), clipRect.Width(), clipRect.Height());
   if (host.PaintCbk(
       PaintArgs.new_(
           GfxAdpBase.new_(g2),
           clipRect))) // ClipRect not used by any clients; implement when necessary
   super.paint(
         g); // Reevaluate if necessary: super.paint might need to (a) always happen and (b) go
             // before PaintCbk (had issues with drawing text on images)
 }
    public void run() {

      try {
        BufferedImage bufferedImage =
            new BufferedImage(_com.getWidth(), _com.getHeight(), BufferedImage.TYPE_INT_RGB);

        // Create a graphics contents on the buffered image
        Graphics2D g2d = bufferedImage.createGraphics();

        _com.paint(g2d);

        File file = new File(_name);
        ImageIO.write(bufferedImage, "jpg", file);
      } catch (Exception ex) {
      }
    }
예제 #14
0
  public void paint(Graphics g) {
    Graphics2D gr = (Graphics2D) g;
    super.paint(g);
    Rectangle bounds = scene.getBounds();
    Dimension size = getSize();

    double sx = bounds.width > 0 ? (double) size.width / bounds.width : 0.0;
    double sy = bounds.width > 0 ? (double) size.height / bounds.height : 0.0;
    double scale = Math.min(sx, sy);

    int vw = (int) (scale * bounds.width);
    int vh = (int) (scale * bounds.height);
    int vx = (size.width - vw) / 2;
    int vy = (size.height - vh) / 2;

    if (image == null || vw != imageWidth || vh != imageHeight) {

      imageWidth = vw;
      imageHeight = vh;
      image = this.createImage(imageWidth, imageHeight);
      Graphics2D ig = (Graphics2D) image.getGraphics();
      ig.scale(scale, scale);
      scene.setRealZoomFactor(scale);
      scene.paint(ig);
      scene.setRealZoomFactor(0.0);
    }

    gr.drawImage(image, vx, vy, this);

    JComponent component = scene.getView();
    double zoomFactor = scene.getZoomFactor();
    Rectangle viewRectangle = component != null ? component.getVisibleRect() : null;
    if (viewRectangle != null) {
      Rectangle window =
          new Rectangle(
              (int) ((double) viewRectangle.x * scale / zoomFactor),
              (int) ((double) viewRectangle.y * scale / zoomFactor),
              (int) ((double) viewRectangle.width * scale / zoomFactor),
              (int) ((double) viewRectangle.height * scale / zoomFactor));
      window.translate(vx, vy);
      gr.setColor(new Color(200, 200, 200, 128));
      gr.fill(window);
      gr.setColor(Color.BLACK);
      gr.drawRect(window.x, window.y, window.width - 1, window.height - 1);
    }
  }
예제 #15
0
  @Override
  public void paint(Graphics g) {
    super.paint(g);

    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    int textWidth = g2.getFontMetrics().stringWidth("00:00.00");
    int fontSize = getFont().getSize() * getWidth() / textWidth;
    g2.setFont(getFont().deriveFont((float) Math.min(fontSize, getHeight())));

    Rectangle2D bounds = g2.getFontMetrics().getStringBounds(this.text, g2);
    g2.drawString(
        this.text,
        (int) ((getWidth() - bounds.getWidth()) / 2 - bounds.getX()),
        (int) ((getHeight() - bounds.getHeight()) / 2 - bounds.getY()));
  }
 /* Methods for DragGestureListener */
 public final void dragGestureRecognized(DragGestureEvent dge) {
   TreePath path = tree.getSelectionPath();
   if (path != null) {
     draggedPath = path;
     draggedNodeParentPath = path.getParentPath();
     if (drawImage) {
       Rectangle pathBounds = tree.getPathBounds(path); // getpathbounds of selectionpath
       JComponent lbl =
           (JComponent)
               tree.getCellRenderer()
                   .getTreeCellRendererComponent(
                       tree,
                       draggedPath.getLastPathComponent(),
                       false,
                       tree.isExpanded(path),
                       false,
                       0,
                       false); // returning the label
       lbl.setBounds(pathBounds); // setting bounds to lbl
       image =
           new BufferedImage(
               lbl.getWidth(),
               lbl.getHeight(),
               java.awt.image.BufferedImage
                   .TYPE_INT_ARGB_PRE); // buffered image reference passing the label's ht and
                                        // width
       Graphics2D graphics = image.createGraphics(); // creating the graphics for buffered image
       graphics.setComposite(
           AlphaComposite.getInstance(
               AlphaComposite.SRC_OVER, 0.5f)); // Sets the Composite for the Graphics2D context
       lbl.setOpaque(false);
       lbl.paint(graphics); // painting the graphics to label
       graphics.dispose();
     }
     dragSource.startDrag(
         dge,
         DragSource.DefaultMoveNoDrop,
         image,
         new Point(0, 0),
         new TransferableNode(draggedPath),
         this);
   }
 }
예제 #17
0
  void test(JComponent c) {
    c.setEnabled(false);
    c.setOpaque(true);
    c.setBackground(TEST_COLOR);
    c.setBorder(null);
    Dimension size = c.getPreferredSize();
    c.setBounds(0, 0, size.width, size.height);

    BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
    c.paint(image.getGraphics());

    int rgb = TEST_COLOR.getRGB();
    for (int i = 0; i < size.height; i++) {
      for (int j = 0; j < size.width; j++) {
        if (image.getRGB(j, i) != rgb) {
          throw new RuntimeException(String.format("Color mismatch at [%d, %d]", j, i));
        }
      }
    }
  }
  private void checkResult(@TestDataFile String expectedResultFileName) throws IOException {
    myEditor.getSettings().setAdditionalLinesCount(0);
    myEditor.getSettings().setAdditionalColumnsCount(1);
    JComponent editorComponent = myEditor.getContentComponent();
    Dimension size = editorComponent.getPreferredSize();
    editorComponent.setSize(size);
    //noinspection UndesirableClassUsage
    BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
    BitmapFont bitmapFont = BitmapFont.loadFromFile(getFontFile());
    MyGraphics graphics = new MyGraphics(image.createGraphics(), bitmapFont);
    try {
      editorComponent.paint(graphics);
    } finally {
      graphics.dispose();
    }

    File fileWithExpectedResult = getTestDataFile(expectedResultFileName);
    if (OVERWRITE_TESTDATA) {
      ImageIO.write(image, "png", fileWithExpectedResult);
      System.out.println("File " + fileWithExpectedResult.getPath() + " created.");
    }
    if (fileWithExpectedResult.exists()) {
      BufferedImage expectedResult = ImageIO.read(fileWithExpectedResult);
      if (expectedResult.getWidth() != image.getWidth()) {
        fail("Unexpected image width", fileWithExpectedResult, image);
      }
      if (expectedResult.getHeight() != image.getHeight()) {
        fail("Unexpected image height", fileWithExpectedResult, image);
      }
      for (int i = 0; i < expectedResult.getWidth(); i++) {
        for (int j = 0; j < expectedResult.getHeight(); j++) {
          if (expectedResult.getRGB(i, j) != image.getRGB(i, j)) {
            fail("Unexpected image contents", fileWithExpectedResult, image);
          }
        }
      }
    } else {
      ImageIO.write(image, "png", fileWithExpectedResult);
      fail("Missing test data created: " + fileWithExpectedResult.getPath());
    }
  }
예제 #19
0
  @Override
  public final void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2 = (Graphics2D) g;
    if (translateForExport) {
      g2.translate(Constants.EXPORT_DISPLACEMENT, Constants.EXPORT_DISPLACEMENT);
    }

    boolean selected = getDiagramHandler().getDrawPanel().getSelector().isSelected(this);
    if (selected) {
      if (SharedConfig.getInstance().isDev_mode()) {
        Color oldColor = g2.getColor();
        g2.setColor(Converter.convert(ColorOwn.BLACK));
        String text = "Type: " + getClass().getName();
        g2.drawString(
            text,
            getWidth() - (int) getDiagramHandler().getFontHandler().getTextWidth(text),
            getHeight() - 5);
        g2.setColor(oldColor);
      }
      if (isDeprecated()) {
        Color oldColor = g2.getColor();
        g2.setColor(
            Converter.convert(ColorOwn.RED.transparency(Transparency.SELECTION_BACKGROUND)));
        g2.fillRect(0, 0, getWidth(), getHeight());
        g2.setColor(oldColor);
        g2.setColor(Converter.convert(ColorOwn.RED.transparency(Transparency.DEPRECATED_WARNING)));
        g2.drawString("DEPRECATED ELEMENT", 10, 15);
        g2.drawString("WILL SOON BE REMOVED", 10, 30);
      }
      fgColor = Converter.convert(ColorOwn.SELECTION_FG);
      if (SharedConfig.getInstance().isShow_stickingpolygon()) {
        drawStickingPolygon(g2);
      }
    } else {
      fgColor = fgColorBase;
    }
    updateModelFromText();
    paintEntity(g2);
  }
 public final void paint(Graphics g) {
   super.paint(g);
 }
  private EditorFragmentComponent(
      EditorEx editor, int startLine, int endLine, boolean showFolding, boolean showGutter) {
    Document doc = editor.getDocument();
    final int endOffset =
        endLine < doc.getLineCount() ? doc.getLineEndOffset(endLine) : doc.getTextLength();
    int textWidth =
        Math.min(
            editor.getMaxWidthInRange(doc.getLineStartOffset(startLine), endOffset),
            ScreenUtil.getScreenRectangle(1, 1).width);
    LOG.assertTrue(
        textWidth > 0,
        "TextWidth: " + textWidth + "; startLine:" + startLine + "; endLine:" + endLine + ";");

    FoldingModelEx foldingModel = editor.getFoldingModel();
    boolean isFoldingEnabled = foldingModel.isFoldingEnabled();
    if (!showFolding) {
      foldingModel.setFoldingEnabled(false);
    }

    Point p1 = editor.logicalPositionToXY(new LogicalPosition(startLine, 0));
    Point p2 = editor.logicalPositionToXY(new LogicalPosition(Math.max(endLine, startLine + 1), 0));
    int y1 = p1.y;
    int y2 = p2.y;
    int height = y2 - y1 == 0 ? editor.getLineHeight() : y2 - y1;
    LOG.assertTrue(
        height > 0,
        "Height: "
            + height
            + "; startLine:"
            + startLine
            + "; endLine:"
            + endLine
            + "; p1:"
            + p1
            + "; p2:"
            + p2);

    int savedScrollOffset = editor.getScrollingModel().getHorizontalScrollOffset();
    if (savedScrollOffset > 0) {
      editor.stopOptimizedScrolling();
      editor.getScrollingModel().scrollHorizontally(0);
    }

    final Image textImage = new BufferedImage(textWidth, height, BufferedImage.TYPE_INT_RGB);
    Graphics textGraphics = textImage.getGraphics();

    final JComponent rowHeader;
    final Image markersImage;
    if (showGutter) {
      rowHeader = editor.getGutterComponentEx();
      markersImage =
          new BufferedImage(Math.max(1, rowHeader.getWidth()), height, BufferedImage.TYPE_INT_RGB);
      Graphics markerGraphics = markersImage.getGraphics();

      markerGraphics.translate(0, -y1);
      markerGraphics.setClip(0, y1, rowHeader.getWidth(), height);
      markerGraphics.setColor(getBackgroundColor(editor));
      markerGraphics.fillRect(0, y1, rowHeader.getWidth(), height);
      rowHeader.paint(markerGraphics);
    } else {
      rowHeader = null;
      markersImage = null;
    }

    textGraphics.translate(0, -y1);
    textGraphics.setClip(0, y1, textWidth, height);
    final boolean wasVisible = editor.setCaretVisible(false);
    editor.setPurePaintingMode(true);
    try {
      editor.getContentComponent().paint(textGraphics);
    } finally {
      editor.setPurePaintingMode(false);
    }
    if (wasVisible) {
      editor.setCaretVisible(true);
    }

    if (!showFolding) {
      foldingModel.setFoldingEnabled(isFoldingEnabled);
    }

    if (savedScrollOffset > 0) {
      editor.stopOptimizedScrolling();
      editor.getScrollingModel().scrollHorizontally(savedScrollOffset);
    }

    JComponent component =
        new JComponent() {
          public Dimension getPreferredSize() {
            return new Dimension(
                textImage.getWidth(null) + (markersImage == null ? 0 : markersImage.getWidth(null)),
                textImage.getHeight(null));
          }

          protected void paintComponent(Graphics graphics) {
            if (markersImage != null) {
              graphics.drawImage(markersImage, 0, 0, null);
              graphics.drawImage(textImage, rowHeader.getWidth(), 0, null);
            } else {
              graphics.drawImage(textImage, 0, 0, null);
            }
          }
        };

    setLayout(new BorderLayout());
    add(component);

    final Color borderColor =
        editor.getColorsScheme().getColor(EditorColors.SELECTED_TEARLINE_COLOR);

    Border outsideBorder = BorderFactory.createLineBorder(borderColor, 1);
    Border insideBorder = BorderFactory.createEmptyBorder(2, 2, 2, 2);
    setBorder(BorderFactory.createCompoundBorder(outsideBorder, insideBorder));
  }
예제 #22
0
 @Override
 public void paint(Graphics g) {
   super.paint(g);
 }
예제 #23
0
  @Override
  public void paint(Graphics grphcs) {
    super.paint(grphcs);

    // Prepare shape
    Graphics2D g2 = (Graphics2D) grphcs;
    int width = getWidth() - 2;
    int height = getHeight() - 2;
    GradientPaint gp = null;

    // Enable antialias
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Render frame
    if (state == STATE_NONE) {

      // Draw shadow
      g2.setColor(Colorset.COLOR_LIGHT_SHADOW);
      g2.drawRoundRect(1, 1, width, height, BORDER_RADIUS, BORDER_RADIUS);

      // Draw fill
      gp =
          new GradientPaint(0f, -height / 4, Colorset.G_SEL_TOP, 0f, height, Colorset.G_SEL_BOTTOM);
      g2.setPaint(gp);
      g2.fillRoundRect(0, 0, width, height, BORDER_RADIUS, BORDER_RADIUS);

      // Draw frame
      g2.setColor(Colorset.COLOR_SHADOW);
      g2.drawRoundRect(0, 0, width, height, BORDER_RADIUS, BORDER_RADIUS);

    } else if (state == STATE_HOVER) {

      // Draw shadow
      g2.setColor(Colorset.COLOR_LIGHT_SHADOW);
      g2.drawRoundRect(1, 1, width, height, BORDER_RADIUS, BORDER_RADIUS);

      // Draw fill
      gp = new GradientPaint(0f, height / 8, Colorset.G_SEL_TOP, 0f, height, Colorset.G_SEL_BOTTOM);
      g2.setPaint(gp);
      g2.fillRoundRect(0, 0, width, height, BORDER_RADIUS, BORDER_RADIUS);

      // Draw frame
      g2.setColor(Colorset.COLOR_SHADOW);
      g2.drawRoundRect(0, 0, width, height, BORDER_RADIUS, BORDER_RADIUS);

    } else if (state == STATE_DOWN) {

      // Draw dark fill
      gp =
          new GradientPaint(
              0f, 0f, Colorset.COLOR_LIGHT_SHADOW, 0f, height, Colorset.G_UNSEL_BOTTOM);
      g2.setPaint(gp);
      g2.fillRoundRect(0, 0, width, height, BORDER_RADIUS, BORDER_RADIUS);

      // Draw frame
      g2.setColor(Colorset.COLOR_DARK_SHADOW);
      g2.drawRoundRect(0, 0, width, height, BORDER_RADIUS, BORDER_RADIUS);
    }

    // Render text
    if (text != null) {
      g2.setColor(textColor);
      FontMetrics fm = g2.getFontMetrics();
      LineMetrics lm = fm.getLineMetrics(text, g2);
      int txtW = fm.stringWidth(text);

      g2.drawString(text, (width - txtW) / 2, (height + fm.getHeight()) / 2 - 2);
    }
  }
예제 #24
0
  public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
    Graphics2D g2d = (Graphics2D) g;
    int page = 0;
    double curY = 0;
    double k = 1.0;

    for (int i = 0; i < componentsToBePrinted.length; i++) {
      JComponent c = (JComponent) componentsToBePrinted[i];
      double pw = pageFormat.getImageableWidth();
      double cw = c.getSize().width;
      double ph = pageFormat.getImageableHeight();
      double ch = c.getSize().height;
      if (cw == 0) {
        cw = pw;
        ch = c.getPreferredSize().height;
        c.setSize((int) cw, (int) ch);
        c.setPreferredSize(new Dimension((int) cw, (int) ch));
      }

      double l = ph / ch;
      if (i == 0 && !isHelpView) {
        k = 1.0;
      } else if (i == 1) {
        k = pw / cw;
        k = Math.min(k, l);
      }

      if (curY + ch * k > pageFormat.getImageableHeight()) {
        curY = 0;
        page++;
      }

      boolean componentPainted = true;
      if (page == pageIndex && g2d != null) {
        g2d.translate((int) pageFormat.getImageableX(), (int) pageFormat.getImageableY() + curY);
        g2d.scale(k, k);
        disableDoubleBuffering(c);

        if (c instanceof Math4u2TextPane) {
          Math4u2TextPane tp = (Math4u2TextPane) c;
          boolean isHistory = tp.isHistory();
          if (tp.getDocument().getLength() != 0) {
            tp.setHistory(false);
            c.paint(g2d);
            tp.setHistory(isHistory);
          } else {
            componentPainted = false;
          }
        } else {
          c.paint(g2d);
        } // else

        enableDoubleBuffering(c);
        g2d.scale(1 / k, 1 / k);
        g2d.translate((int) -pageFormat.getImageableX(), (int) -pageFormat.getImageableY() - curY);
      } // if

      if (componentPainted) {
        curY += ch * k + 10;
      } // if
    } // for i
    if (page < pageIndex) return NO_SUCH_PAGE;
    else return PAGE_EXISTS;
  } // print
예제 #25
0
 public void paint(Graphics g) {
   super.paint(g);
   // LineMetrics _metrics = _font.
 }
예제 #26
0
  public void paint(Graphics g) {
    super.paint(g);
    /*
    g.setFont(getFont());
    if (transcript == null)
      return;

    rh.removeAll();

    //    int length = editorPanel.
    //                 getSequenceForTier(editorPanel.getSelectedTier()).getLength();

    translationStart = transcript.getTranslationStart();
    int laststart_base = transcript.getPositionFrom(translationStart, 2);
    translationEnd = transcript.getTranslationEnd();
    int laststop_base = transcript.getLastBaseOfStopCodon();
    int readthrough_pos = transcript.readThroughStopPosition();
    int lastreadon_base = transcript.getPositionFrom(readthrough_pos, 2);

    int topDistance = (getSize().height - barHeight) / 2;
    java.util.Vector exons = transcript.getExons();
    int exon_count = exons.size();
    int featureWidth;

    // if we want to see the introns then set featureWidth to the transcript
    // length and draw a rectangle.
    if (drawIntrons) {
      featureWidth = (int) transcript.length();
      int lowPos = editorPanel.getAnnotationPanel()
        .basePairToPosition((int)transcript.getLow());
      int highPos = editorPanel.getAnnotationPanel()
        .basePairToPosition((int)transcript.getHigh());
      //int lineColorIndex = (editorPanel.getRangeIndex(tier,
        //                    lowPos,
        //                    highPos)
        //                    % colorList.length);

      //g.setColor(colorList[lineColorIndex][0]);
      g.setColor(editorPanel.getIndicatorColor());

      g.fillRect(margin,
                 (getSize().height - 2) / 2,
                 getSize().width - margin*2 - 1,
                 3);

    } else {
      featureWidth = 0;
      for(int i=0; i < exon_count; i++) {
        SeqFeatureI feature = (SeqFeatureI) exons.elementAt(i);
        featureWidth += (int) feature.length();
      }
    }

    double scaling_factor = ((double) featureWidth /
                             (double) (getSize().width - margin*2));

    int x = margin;
    // Loop through exons
    for(int i=0; i < exon_count; i++) {
      ExonI exon = transcript.getExonAt(i);
      int low = (int) exon.getLow();
      int high = (int) exon.getHigh();
      int lowPos = editorPanel.getAnnotationPanel().basePairToPosition(low);
      int highPos = editorPanel.getAnnotationPanel().basePairToPosition(high);

      int width = (int) Math.floor(exon.length() / scaling_factor);
      if (width < 1)
        width = 1;

     // int transcriptColorIndex = (editorPanel.getRangeIndex(tier,
    //                              lowPos,
    //                              highPos)
    //                              % colorList.length);

    //  int exonColorIndex = (editorPanel.getExonRangeIndex(tier,
    //                        lowPos,
    //                        highPos)
    //                        % colorList[transcriptColorIndex].length);

     // g.setColor(colorList[transcriptColorIndex][exonColorIndex]);
      g.setColor(Color.blue); //TODO: change

      int drawX = x;

      rh.put(drawX, drawX+width-1, exon);

      g.fillRect(drawX,
                 topDistance,
                 width,
                 barHeight+1);

      // paint the codons
      paintCodon (g,
                  exon,
                  translationStart, laststart_base,
                  low, high,
                  DrawableUtil.getStartCodonColor(transcript),
                  x, topDistance, scaling_factor);

      paintCodon (g,
                  exon,
                  translationEnd, laststop_base,
                  low, high,
                  Color.red,
                  x, topDistance, scaling_factor);

      paintCodon (g,
                  exon,
                  readthrough_pos, lastreadon_base,
                  low, high,
                  Color.pink,
                  x, topDistance, scaling_factor);

      // If exon is coding draw in frame number - what is the first frame?X
      paintFrame(g, exon, low, high, translationStart, laststop_base,
                 x, topDistance, scaling_factor);

      // increment x
      x += width;
      if (drawIntrons && (i + 1) < exon_count) {
        ExonI nextExon = transcript.getExonAt (i+1);
        int intron_len = (int) (exon.getStrand() == 1 ?
                                (nextExon.getLow() - high + 1) :
                                (low - nextExon.getHigh() + 1));
        x += (intron_len / scaling_factor);
      }
    } // end of exon loop

    int baseStart = editorPanel.getVisibleBase();
    int baseCount = editorPanel.getVisibleBaseCount();
    int baseOffset = baseStart - (int) transcript.getStart();
    if (editorPanel.getStrand() == Strand.REVERSE)
      baseOffset = (int) transcript.getStart() - baseStart;
    int pixelOffset = (int) ((double) baseOffset / scaling_factor);
    int basePixelStart = margin+pixelOffset;
    int basePixelCount = (int) ((double) baseCount /
                                (double) scaling_factor);

    //    g.setColor(Color.yellow);
    // Box that goes over exon diagram at the bottom to show which region
    // you're seeing in the detailed view
    g.setColor(Color.black); //TODO config
    g.drawRect(basePixelStart, topDistance-4,
               basePixelCount, barHeight+8);
    // To make a two-pixel-wide rectangle, draw a one-pixel-bigger rectangle
    // around the first one
    g.drawRect(basePixelStart-1, topDistance-5,
               basePixelCount+2, barHeight+10);*/
  }