~ubuntu-branches/ubuntu/quantal/libjgraph-java/quantal

« back to all changes in this revision

Viewing changes to src/org/jgraph/plaf/basic/BasicGraphUI.java

  • Committer: Bazaar Package Importer
  • Author(s): gregor herrmann
  • Date: 2007-09-17 18:45:29 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070917184529-3a2otncixn4dh2ye
Tags: 5.10.1.5.dfsg-1
* New upstream release.
* Clean up debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
928
928
                                int volatileContentsLostCount = 0;
929
929
                                do {
930
930
                                        offGraphics = graph.getOffgraphics();
931
 
                                        if (!graph.isOffscreenValid()) {
932
 
                                                Rectangle2D offGraphicsClip = (Rectangle2D) offGraphics
933
 
                                                                .getClipBounds();
934
 
                                                if (offGraphicsClip != null) {
935
 
                                                        offGraphicsClip = (Rectangle2D) offGraphicsClip
936
 
                                                                        .clone();
937
 
                                                }
938
 
                                                if (offGraphicsClip != null && clipBounds != null) {
939
 
                                                        Rectangle2D.union(offGraphicsClip, clipBounds,
940
 
                                                                        offGraphicsClip);
941
 
                                                }
942
 
                                                renderOffscreen(offGraphics,
943
 
                                                                (offGraphicsClip == null) ? clipBounds
944
 
                                                                                : offGraphicsClip);
945
 
                                        }
946
931
                                        volatileContentsLostCount++;
947
932
                                        if (volatileContentsLostCount > 10) {
948
933
                                                // Assume a problem with the volatile buffering
950
935
                                                graph.setVolatileOffscreen(false);
951
936
                                        }
952
937
                                } while (((VolatileImage) offscreen).contentsLost());
953
 
                        } else if (offscreen instanceof BufferedImage) {
954
 
                                if (!graph.isOffscreenValid()) {
955
 
                                        Rectangle2D offGraphicsClip = offGraphics.getClipBounds();
956
 
                                        if (offGraphicsClip != null) {
957
 
                                                offGraphicsClip = (Rectangle2D) offGraphicsClip.clone();
958
 
                                        }
959
 
                                        if (offGraphicsClip != null && clipBounds != null) {
960
 
                                                Rectangle2D.union(offGraphicsClip, clipBounds,
961
 
                                                                offGraphicsClip);
962
 
                                        }
963
 
                                        renderOffscreen(offGraphics,
964
 
                                                        (offGraphicsClip == null) ? clipBounds
965
 
                                                                        : offGraphicsClip);
966
 
                                }
967
938
                        }
968
939
                        graph.setOffscreenValid(true);
969
940
                        g.drawImage(graph.getOffscreen(), 0, 0, graph);
1002
973
         * @param clipBounds
1003
974
         *            the bounds within graph cells must intersect to be redrawn
1004
975
         */
1005
 
        protected void drawGraph(Graphics g, Rectangle2D clipBounds) {
 
976
        public void drawGraph(Graphics g, Rectangle2D clipBounds) {
1006
977
                Rectangle2D realClipBounds = null;
1007
978
                if (clipBounds != null) {
1008
979
                        Rectangle2D paintBounds = new Rectangle2D.Double(clipBounds.getX(),
2472
2443
                        }
2473
2444
                        try {
2474
2445
                                offgraphics = graph.getOffgraphics();
2475
 
                                if (!graph.isOffscreenValid()) {
2476
 
                                        graph.getUI().paint(offgraphics, graph);
2477
 
                                }
2478
2446
                        } catch (Exception e) {
2479
2447
                                offgraphics = null;
2480
2448
                        } catch (Error e) {
2526
2494
                                                        dy = constrainedPosition.getY();
2527
2495
                                                }
2528
2496
                                                double scale = graph.getScale();
2529
 
                                                dx = (int) (dx / scale);
2530
 
                                                // we don't want to round. The best thing is to get just
2531
 
                                                // the integer part.
2532
 
                                                // That way, the view won't "run away" from the mouse.
2533
 
                                                // It may lag behind
2534
 
                                                // a mouse pointer occasionally, but will be catching
2535
 
                                                // up.
2536
 
                                                dy = (int) (dy / scale);
 
2497
                                                dx = dx / scale;
 
2498
                                                dy = dy / scale;
2537
2499
                                                // Start Drag and Drop
2538
2500
                                                if (graph.isDragEnabled() && !isDragging)
2539
2501
                                                        startDragging(event);
2793
2755
                                                activeHandle = null;
2794
2756
                                        } else if (isMoving && !event.getPoint().equals(start)) {
2795
2757
                                                if (cachedBounds != null) {
2796
 
                                                        double dx = event.getX() - start.getX();
2797
 
                                                        double dy = event.getY() - start.getY();
 
2758
                                                        
 
2759
                                                        Point ep = event.getPoint();
 
2760
                                                        Point2D point = new Point2D.Double(ep.getX()
 
2761
                                                                        - _mouseToViewDelta_x, ep.getY()
 
2762
                                                                        - _mouseToViewDelta_y);
 
2763
                                                        Point2D snapCurrent = graph.snap(point);
 
2764
                                                        
 
2765
                                                        double dx = snapCurrent.getX() - start.getX();
 
2766
                                                        double dy = snapCurrent.getY() - start.getY();
 
2767
                                                        
2798
2768
                                                        Point2D tmp = graph.fromScreen(new Point2D.Double(
2799
2769
                                                                        dx, dy));
2800
2770
                                                        GraphLayoutCache.translateViews(views, tmp.getX(),