Changeset 4393
- Timestamp:
- 2003-05-28T14:47:44+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java
r4378 r4393 191 191 setSelectionPath(path); 192 192 } 193 if(path == null) { 194 return; 195 } 193 196 if (!isValidDrag()) { 194 197 return; … … 200 203 group.grabFocus(this); 201 204 // Ghost Image stuff. 202 if(path != null) { 203 Rectangle rect = this.getPathBounds(path); 204 group.mouse_offset = new Point(origin.x - rect.x, origin.y - rect.y); 205 // Create the ghost image. 206 // Retrieve the selected files. 207 int selection_count = getSelectionCount(); 208 if(selection_count > 0) { 209 JLabel label; 210 if(selection_count == 1) { 211 TreePath node_path = getSelectionPath(); 212 FileNode node = (FileNode) path.getLastPathComponent(); 213 label = new JLabel(node.toString(), ((DefaultTreeCellRenderer)getCellRenderer()).getLeafIcon(), JLabel.CENTER); 214 } 215 else { 216 String title = getSelectionCount() + " files"; 217 label = new JLabel(title, ((DefaultTreeCellRenderer)getCellRenderer()).getClosedIcon(), JLabel.CENTER); 218 title = null; 219 } 220 // The layout manager normally does this. 221 Dimension label_size = label.getPreferredSize(); 222 label.setSize(label_size); 223 label.setBackground(TRANSPARENT_COLOR); 224 label.setOpaque(true); 225 // Get a buffered image of the selection for dragging a ghost image. 226 group.image_ghost = new BufferedImage(label_size.width, label_size.height, BufferedImage.TYPE_INT_ARGB_PRE); 227 label_size = null; 228 // Get a graphics context for this image. 229 Graphics2D g2 = group.image_ghost.createGraphics(); 230 // Make the image ghostlike 231 g2.setComposite(AlphaComposite.getInstance (AlphaComposite.SRC, 0.5f)); 232 // Ask the cell renderer to paint itself into the BufferedImage 233 label.paint(g2); 234 g2 = null; 235 label = null; 236 try { 237 event.startDrag(new Cursor(Cursor.DEFAULT_CURSOR), group.image_ghost, new Point(5,5), new StringSelection("dummy"), this); 238 //dragging = true; 239 } 240 catch(Exception error) { 241 error.printStackTrace(); 242 } 243 } 244 } 205 Rectangle rect = this.getPathBounds(path); 206 group.mouse_offset = new Point(origin.x - rect.x, origin.y - rect.y); 207 // Create the ghost image. 208 // Retrieve the selected files. 209 int selection_count = getSelectionCount(); 210 if(selection_count > 0) { 211 JLabel label; 212 if(selection_count == 1) { 213 TreePath node_path = getSelectionPath(); 214 FileNode node = (FileNode) path.getLastPathComponent(); 215 label = new JLabel(node.toString(), ((DefaultTreeCellRenderer)getCellRenderer()).getLeafIcon(), JLabel.CENTER); 216 } 217 else { 218 String title = getSelectionCount() + " files"; 219 label = new JLabel(title, ((DefaultTreeCellRenderer)getCellRenderer()).getClosedIcon(), JLabel.CENTER); 220 title = null; 221 } 222 // The layout manager normally does this. 223 Dimension label_size = label.getPreferredSize(); 224 label.setSize(label_size); 225 label.setBackground(TRANSPARENT_COLOR); 226 label.setOpaque(true); 227 // Get a buffered image of the selection for dragging a ghost image. 228 group.image_ghost = new BufferedImage(label_size.width, label_size.height, BufferedImage.TYPE_INT_ARGB_PRE); 229 label_size = null; 230 // Get a graphics context for this image. 231 Graphics2D g2 = group.image_ghost.createGraphics(); 232 // Make the image ghostlike 233 g2.setComposite(AlphaComposite.getInstance (AlphaComposite.SRC, 0.5f)); 234 // Ask the cell renderer to paint itself into the BufferedImage 235 label.paint(g2); 236 g2 = null; 237 label = null; 238 try { 239 event.startDrag(new Cursor(Cursor.DEFAULT_CURSOR), group.image_ghost, new Point(5,5), new StringSelection("dummy"), this); 240 //dragging = true; 241 } 242 catch(Exception error) { 243 error.printStackTrace(); 244 } 245 } 246 245 247 } 246 248
Note:
See TracChangeset
for help on using the changeset viewer.