Package javax.swing

Examples of javax.swing.RepaintManager$PaintManager


        graphics.setComposite(AlphaComposite.SrcOver);
      }
      graphics.translate((int) (-bounds.getX() + inset), (int) (-bounds
          .getY() + inset));
      boolean tmp = isDoubleBuffered();
      RepaintManager currentManager = RepaintManager.currentManager(this);
      currentManager.setDoubleBufferingEnabled(false);
      paint(graphics);
      currentManager.setDoubleBufferingEnabled(tmp);
      return img;
    }
    return null;
  }
View Full Code Here


    int rows = (int) Math.max(Math.ceil((double) (pSize.height - 5)
        / (double) h), 1);
    if (page < cols * rows) {

      // Configures graph for printing
      RepaintManager currentManager = RepaintManager.currentManager(this);
      currentManager.setDoubleBufferingEnabled(false);
      double oldScale = getGraph().getScale();
      getGraph().setScale(1 / pageScale);
      int dx = (int) ((page % cols) * printFormat.getWidth());
      int dy = (int) ((page % rows) * printFormat.getHeight());
      g.translate(-dx, -dy);
      g.setClip(dx, dy, (int) (dx + printFormat.getWidth()),
          (int) (dy + printFormat.getHeight()));

      // Prints the graph on the graphics.
      getGraph().paint(g);

      // Restores graph
      g.translate(dx, dy);
      graph.setScale(oldScale);
      currentManager.setDoubleBufferingEnabled(true);
      return PAGE_EXISTS;
    } else {
      return NO_SUCH_PAGE;
    }
  }
View Full Code Here

  public int print(Graphics g, PageFormat printFormat, int page)
  {
    int result = NO_SUCH_PAGE;

    // Disables double-buffering before printing
    RepaintManager currentManager = RepaintManager
        .currentManager(mxGraphComponent.this);
    currentManager.setDoubleBufferingEnabled(false);

    // Gets the current state of the view
    mxGraphView view = graph.getView();

    // Stores the old state of the view
    boolean eventsEnabled = view.isEventsEnabled();
    mxPoint translate = view.getTranslate();

    // Disables firing of scale events so that there is no
    // repaint or update of the original graph while pages
    // are being printed
    view.setEventsEnabled(false);

    // Uses the view to create temporary cell states for each cell
    mxTemporaryCellStates tempStates = new mxTemporaryCellStates(view,
        1 / pageScale);

    try
    {
      view.setTranslate(new mxPoint(0, 0));

      mxGraphics2DCanvas canvas = createCanvas();
      canvas.setGraphics((Graphics2D) g);
      canvas.setScale(1 / pageScale);

      view.revalidate();

      mxRectangle graphBounds = graph.getGraphBounds();
      Dimension pSize = new Dimension((int) Math.ceil(graphBounds.getX()
          + graphBounds.getWidth()) + 1, (int) Math.ceil(graphBounds
          .getY() + graphBounds.getHeight()) + 1);

      int w = (int) (printFormat.getImageableWidth());
      int h = (int) (printFormat.getImageableHeight());
      int cols = (int) Math.max(
          Math.ceil((double) (pSize.width - 5) / (double) w), 1);
      int rows = (int) Math.max(
          Math.ceil((double) (pSize.height - 5) / (double) h), 1);

      if (page < cols * rows)
      {
        int dx = (int) ((page % cols) * printFormat.getImageableWidth());
        int dy = (int) (Math.floor(page / cols) * printFormat
            .getImageableHeight());

        g.translate(-dx + (int) printFormat.getImageableX(), -dy
            + (int) printFormat.getImageableY());
        g.setClip(dx, dy, (int) (dx + printFormat.getWidth()),
            (int) (dy + printFormat.getHeight()));

        graph.drawGraph(canvas);

        result = PAGE_EXISTS;
      }
    }
    finally
    {
      view.setTranslate(translate);

      tempStates.destroy();
      view.setEventsEnabled(eventsEnabled);

      // Enables double-buffering after printing
      currentManager.setDoubleBufferingEnabled(true);
    }

    return result;
  }
View Full Code Here

   *
   * @param c
   *          the c
   */
  private static void disableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(false);
  }
View Full Code Here

   *
   * @param c
   *          the c
   */
  private static void enableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(true);
  }
View Full Code Here

    /**
     * Temporary hack prior to setting up proper fest-swing tests.
     */
    @BeforeClass
    public static void setupOnce() {
        RepaintManager rm = new RepaintManager();
        FailOnThreadViolationRepaintManager.setCurrentManager(rm);
    }
View Full Code Here

      sourceScrollValue=m_sourceScroll.getVerticalScrollBar().getValue();
      targetScrollValue=m_targetScroll.getVerticalScrollBar().getValue();
    }

    public void finishPrinting(){
        RepaintManager currentManager = RepaintManager.currentManager(m_treePanel);
        currentManager.setDoubleBufferingEnabled(true);
        bSkipPainting=false;
        initComponentSize();
        adjustComponentSize();
        m_sourceScroll.getVerticalScrollBar().setValue(sourceScrollValue);
        m_targetScroll.getVerticalScrollBar().setValue(targetScrollValue);
View Full Code Here

                }

                Graphics2D g2d = (Graphics2D)graphics;
                g2d.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
                g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY()-pageIndex*pageFormat.getImageableHeight());
                RepaintManager currentManager = RepaintManager.currentManager(m_treePanel);
                currentManager.setDoubleBufferingEnabled(false);

                if(!bPrintingInitialized){
                  initComponentSize((int)pageFormat.getImageableWidth(), height);
                  bPrintingInitialized=true;
                }
View Full Code Here

    public static void enableDoubleBuffering(Component c) {
        setDoubleBufferingEnabled(c, true);
    }

    private static void setDoubleBufferingEnabled(Component c, boolean enabled) {
        RepaintManager currentManager = RepaintManager.currentManager(c);
        currentManager.setDoubleBufferingEnabled(enabled);
    }
View Full Code Here

  public int print(Graphics g, PageFormat printFormat, int page)
  {
    int result = NO_SUCH_PAGE;

    // Disables double-buffering before printing
    RepaintManager currentManager = RepaintManager
        .currentManager(mxGraphComponent.this);
    currentManager.setDoubleBufferingEnabled(false);

    // Gets the current state of the view
    mxGraphView view = graph.getView();

    // Stores the old state of the view
    boolean eventsEnabled = view.isEventsEnabled();
    mxPoint translate = view.getTranslate();

    // Disables firing of scale events so that there is no
    // repaint or update of the original graph while pages
    // are being printed
    view.setEventsEnabled(false);

    // Uses the view to create temporary cell states for each cell
    mxTemporaryCellStates tempStates = new mxTemporaryCellStates(view,
        1 / pageScale);

    try
    {
      view.setTranslate(new mxPoint(0, 0));

      mxGraphics2DCanvas canvas = createCanvas();
      canvas.setGraphics((Graphics2D) g);

      view.revalidate();

      mxRectangle graphBounds = graph.getGraphBounds();
      Dimension pSize = new Dimension((int) Math.ceil(graphBounds.getX()
          + graphBounds.getWidth()) + 1, (int) Math.ceil(graphBounds
          .getY() + graphBounds.getHeight()) + 1);

      int w = (int) (printFormat.getImageableWidth());
      int h = (int) (printFormat.getImageableHeight());
      int cols = (int) Math.max(
          Math.ceil((double) (pSize.width - 5) / (double) w), 1);
      int rows = (int) Math.max(
          Math.ceil((double) (pSize.height - 5) / (double) h), 1);

      if (page < cols * rows)
      {
        int dx = (int) ((page % cols) * printFormat.getImageableWidth());
        int dy = (int) (Math.floor(page / cols) * printFormat
            .getImageableHeight());

        g.translate(-dx + (int) printFormat.getImageableX(), -dy
            + (int) printFormat.getImageableY());
        g.setClip(dx, dy, (int) (dx + printFormat.getWidth()),
            (int) (dy + printFormat.getHeight()));

        graph.drawGraph(canvas);

        result = PAGE_EXISTS;
      }
    }
    finally
    {
      view.setTranslate(translate);

      tempStates.destroy();
      view.setEventsEnabled(eventsEnabled);

      // Enables double-buffering after printing
      currentManager.setDoubleBufferingEnabled(true);
    }

    return result;
  }
View Full Code Here

TOP

Related Classes of javax.swing.RepaintManager$PaintManager

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.