/** Check the bounds of given line with the bounds of this pane. Optionally * calculate the new bounds in current pane's boundary. * @param comp * @return */ synchronized static public DropGlassPane getDefault(JComponent comp) { Integer id = new Integer(System.identityHashCode(comp)); if ((map.get(id)) == null) { DropGlassPane dgp = new DropGlassPane(); dgp.setOpaque(false); map.put(id, dgp); } return map.get(id); }
private void checkStoredGlassPane() { // remember current glass pane to set back at end of dragging over this compoment if (!DropGlassPane.isOriginalPaneStored()) { Component comp = tree.getRootPane().getGlassPane(); DropGlassPane.setOriginalPane(tree, comp, comp.isVisible()); // set glass pane for paint selection line dropPane = DropGlassPane.getDefault(tree); tree.getRootPane().setGlassPane(dropPane); dropPane.revalidate(); dropPane.setVisible(true); } }
private void stopDragging() { removeDropLine(); removeTimer(); // set back the remembered glass pane if (DropGlassPane.isOriginalPaneStored()) { DropGlassPane.putBackOriginal(); } }
/** Unset drop line if setVisible to false. * @param boolean aFlag new state */ public void setVisible (boolean aFlag) { super.setVisible(aFlag); if (!aFlag) setDropLine (null); }
/** Check the bounds of given line with the bounds of this pane. Optionally * calculate the new bounds in current pane's boundary. * @param line a line for check * @return a line with bounds inside the pane's boundary */ private Line2D checkLineBounds (Line2D line) { Rectangle bounds = getBounds(); double startPointX, startPointY, endPointX, endPointY; // check start point startPointX = Math.max (line.getX1 (), bounds.x+MIN_X); startPointY = Math.max (line.getY1 (), bounds.y+MIN_Y); // check end point endPointX = Math.min (line.getX2 (), (bounds.x+bounds.width)-MIN_WIDTH); endPointY = Math.min (line.getY2 (), (bounds.y+bounds.height)-MIN_HEIGTH); // set new bounds line.setLine(startPointX, startPointY, endPointX, endPointY); return line; }
/** Unset drop line if setVisible to false. * @param boolean aFlag new state */ @Override public void setVisible(boolean aFlag) { super.setVisible(aFlag); if (!aFlag) { setDropLine(null); } }
/** Check the bounds of given line with the bounds of this pane. Optionally * calculate the new bounds in current pane's boundary. * @param line a line for check * @return a line with bounds inside the pane's boundary */ private Line2D checkLineBounds (Line2D line) { Rectangle bounds = getBounds(); double startPointX, startPointY, endPointX, endPointY; // check start point startPointX = Math.max (line.getX1 (), bounds.x+MIN_X); startPointY = Math.max (line.getY1 (), bounds.y+MIN_Y); // check end point endPointX = Math.min (line.getX2 (), (bounds.x+bounds.width)-MIN_WIDTH); endPointY = Math.min (line.getY2 (), (bounds.y+bounds.height)-MIN_HEIGTH); // set new bounds line.setLine(startPointX, startPointY, endPointX, endPointY); return line; }
/** Paint drop line on glass pane. * @param Graphics g Obtained graphics */ public void paint(Graphics g) { if (line!=null) { // check bounds line = checkLineBounds (line); int x1 = (int)line.getX1 (); int x2 = (int)line.getX2 (); int y1 = (int)line.getY1 (); // int y2 = (int)line.getY2 (); actually not used // LINE g.drawLine (x1+2, y1, x2-2, y1); g.drawLine (x1+2, y1+1, x2-2, y1+1); // RIGHT g.drawLine (x1, y1-2, x1, y1+3); g.drawLine (x1+1, y1-1, x1+1, y1+2); // LEFT g.drawLine (x2, y1-2, x2, y1+3); g.drawLine (x2-1, y1-1, x2-1, y1+2); } // help indication of glass pane for debugging /*g.drawLine (0, getBounds ().height / 2, getBounds ().width, getBounds ().height / 2); g.drawLine (0, getBounds ().height / 2+1, getBounds ().width, getBounds ().height / 2+1); g.drawLine (getBounds ().width / 2, 0, getBounds ().width / 2, getBounds ().height); g.drawLine (getBounds ().width / 2+1, 0, getBounds ().width / 2+1, getBounds ().height); */ } }
private void checkStoredGlassPane () { // remember current glass pane to set back at end of dragging over this compoment if (!DropGlassPane.isOriginalPaneStored ()) { Component comp = tree.getRootPane ().getGlassPane (); DropGlassPane.setOriginalPane (tree, comp, comp.isVisible ()); // set glass pane for paint selection line dropPane = DropGlassPane.getDefault (tree); tree.getRootPane ().setGlassPane (dropPane); dropPane.revalidate(); dropPane.setVisible (true); } }
private void stopDragging() { removeDropLine(); removeTimer(); // set back the remembered glass pane if (DropGlassPane.isOriginalPaneStored()) { DropGlassPane.putBackOriginal(); } }
/** Unset drop line if setVisible to false. * @param boolean aFlag new state */ public void setVisible (boolean aFlag) { super.setVisible(aFlag); if (!aFlag) setDropLine (null); }
/** Check the bounds of given line with the bounds of this pane. Optionally * calculate the new bounds in current pane's boundary. * @param comp * @return */ synchronized static public DropGlassPane getDefault (JComponent comp) { Integer id = new Integer (System.identityHashCode (comp)); if ((map.get (id))==null) { DropGlassPane dgp = new DropGlassPane (); dgp.setOpaque (false); map.put (id, dgp); } return (DropGlassPane)map.get (id); }
/** Check the bounds of given line with the bounds of this pane. Optionally * calculate the new bounds in current pane's boundary. * @param line a line for check * @return a line with bounds inside the pane's boundary */ private Line2D checkLineBounds(Line2D line) { Rectangle bounds = getBounds(); double startPointX; double startPointY; double endPointX; double endPointY; // check start point startPointX = Math.max(line.getX1(), bounds.x + MIN_X); startPointY = Math.max(line.getY1(), bounds.y + MIN_Y); // check end point endPointX = Math.min(line.getX2(), (bounds.x + bounds.width) - MIN_WIDTH); endPointY = Math.min(line.getY2(), (bounds.y + bounds.height) - MIN_HEIGTH); // set new bounds line.setLine(startPointX, startPointY, endPointX, endPointY); return line; }
/** Paint drop line on glass pane. * @param Graphics g Obtained graphics */ public void paint(Graphics g) { if (line!=null) { // check bounds line = checkLineBounds (line); int x1 = (int)line.getX1 (); int x2 = (int)line.getX2 (); int y1 = (int)line.getY1 (); // int y2 = (int)line.getY2 (); actually not used // LINE g.drawLine (x1+2, y1, x2-2, y1); g.drawLine (x1+2, y1+1, x2-2, y1+1); // RIGHT g.drawLine (x1, y1-2, x1, y1+3); g.drawLine (x1+1, y1-1, x1+1, y1+2); // LEFT g.drawLine (x2, y1-2, x2, y1+3); g.drawLine (x2-1, y1-1, x2-1, y1+2); } // help indication of glass pane for debugging /*g.drawLine (0, getBounds ().height / 2, getBounds ().width, getBounds ().height / 2); g.drawLine (0, getBounds ().height / 2+1, getBounds ().width, getBounds ().height / 2+1); g.drawLine (getBounds ().width / 2, 0, getBounds ().width / 2, getBounds ().height); g.drawLine (getBounds ().width / 2+1, 0, getBounds ().width / 2+1, getBounds ().height); */ } }
private void checkStoredGlassPane () { // remember current glass pane to set back at end of dragging over this compoment if (!DropGlassPane.isOriginalPaneStored ()) { Component comp = tree.getRootPane ().getGlassPane (); DropGlassPane.setOriginalPane (tree, comp, comp.isVisible ()); // set glass pane for paint selection line dropPane = DropGlassPane.getDefault (tree); tree.getRootPane ().setGlassPane (dropPane); dropPane.revalidate(); dropPane.setVisible (true); } }
private void stopDragging() { removeDropLine (); removeTimer (); // set back the remembered glass pane if (DropGlassPane.isOriginalPaneStored()) { DropGlassPane.putBackOriginal (); } }
private void removeDropLine() { dropPane.setDropLine(null); if (lastNodeArea != null) { repaint(lastNodeArea); lastNodeArea = null; } }
/** Check the bounds of given line with the bounds of this pane. Optionally * calculate the new bounds in current pane's boundary. * @param comp * @return */ synchronized static public DropGlassPane getDefault (JComponent comp) { Integer id = new Integer (System.identityHashCode (comp)); if ((map.get (id))==null) { DropGlassPane dgp = new DropGlassPane (); dgp.setOpaque (false); map.put (id, dgp); } return (DropGlassPane)map.get (id); }
private void checkStoredGlassPane() { // remember current glass pane to set back at end of dragging over this compoment if (!DropGlassPane.isOriginalPaneStored()) { Component comp = table.getRootPane().getGlassPane(); DropGlassPane.setOriginalPane(table, comp, comp.isVisible()); // set glass pane for paint selection line dropPane = DropGlassPane.getDefault(table); table.getRootPane().setGlassPane(dropPane); dropPane.revalidate(); dropPane.setVisible(true); log("dropPane was set"); // NOI18N } }