rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
|---|---|---|
try {
|
public void close() throws IOException { try { closeConnection(); } finally { fireConnectionEvent(ConnectionEvent.CONNECTION_CLOSED); } }
|
|
finally { fireConnectionEvent(ConnectionEvent.CONNECTION_CLOSED); } }
|
public void close() throws IOException { try { closeConnection(); } finally { fireConnectionEvent(ConnectionEvent.CONNECTION_CLOSED); } }
|
|
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
protected String getURI() { StringBuffer buf = new StringBuffer(); buf.append(secure ? "https://" : "http://"); buf.append(hostname); if (secure) { if (port != HTTPConnection.HTTPS_PORT) { buf.append(':'); buf.append(port); } } else { if (port != HTTPConnection.HTTP_PORT) { buf.append(':'); buf.append(port); } } return buf.toString(); }
|
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
public Request newRequest(String method, String path) { if (method == null || method.length() == 0) { throw new IllegalArgumentException("method must have non-zero length"); } if (path == null || path.length() == 0) { path = "/"; } Request ret = new Request(this, method, path); if ((secure && port != HTTPS_PORT) || (!secure && port != HTTP_PORT)) { ret.setHeader("Host", hostname + ":" + port); } else { ret.setHeader("Host", hostname); } ret.setHeader("User-Agent", userAgent); ret.setHeader("Connection", "keep-alive"); ret.setHeader("Accept-Encoding", "chunked;q=1.0, gzip;q=0.9, deflate;q=0.8, " + "identity;q=0.6, *;q=0"); if (cookieManager != null) { Cookie[] cookies = cookieManager.getCookies(hostname, secure, path); if (cookies != null && cookies.length > 0) { StringBuffer buf = new StringBuffer(); buf.append("$Version=1"); for (int i = 0; i < cookies.length; i++) { buf.append(','); buf.append(' '); buf.append(cookies[i].toString()); } ret.setHeader("Cookie", buf.toString()); } } fireRequestEvent(RequestEvent.REQUEST_CREATED, ret); return ret; }
|
fireRequestEvent(RequestEvent.REQUEST_CREATED, ret);
|
public Request newRequest(String method, String path) { if (method == null || method.length() == 0) { throw new IllegalArgumentException("method must have non-zero length"); } if (path == null || path.length() == 0) { path = "/"; } Request ret = new Request(this, method, path); if ((secure && port != HTTPS_PORT) || (!secure && port != HTTP_PORT)) { ret.setHeader("Host", hostname + ":" + port); } else { ret.setHeader("Host", hostname); } ret.setHeader("User-Agent", userAgent); ret.setHeader("Connection", "keep-alive"); ret.setHeader("Accept-Encoding", "chunked;q=1.0, gzip;q=0.9, deflate;q=0.8, " + "identity;q=0.6, *;q=0"); if (cookieManager != null) { Cookie[] cookies = cookieManager.getCookies(hostname, secure, path); if (cookies != null && cookies.length > 0) { StringBuffer buf = new StringBuffer(); buf.append("$Version=1"); for (int i = 0; i < cookies.length; i++) { buf.append(','); buf.append(' '); buf.append(cookies[i].toString()); } ret.setHeader("Cookie", buf.toString()); } } fireRequestEvent(RequestEvent.REQUEST_CREATED, ret); return ret; }
|
|
MetalUtils.fillMetalPattern(g, 2, 2, s.width - 4, s.height - 4,
|
MetalUtils.fillMetalPattern(splitPane, g, 2, 2, s.width - 4, s.height - 4,
|
public void paint(Graphics g) { //super.paint(g); Dimension s = getSize(); MetalUtils.fillMetalPattern(g, 2, 2, s.width - 4, s.height - 4, light, dark); }
|
write8(OSIZE_PREFIX);
|
public void writeSTOSD() { write8(OSIZE_PREFIX); write8(0xAB); }
|
|
write8(OSIZE_PREFIX);
|
public void writeSTOSW() { write8(0xAB); }
|
|
public BufferedImage(ColorModel colormodel, WritableRaster writableraster, boolean premultiplied, Hashtable properties)
|
public BufferedImage(int w, int h, int type)
|
public BufferedImage(ColorModel colormodel, WritableRaster writableraster, boolean premultiplied, Hashtable properties) { init(colormodel, writableraster, premultiplied, properties, TYPE_CUSTOM); // TODO: perhaps try to identify type? }
|
init(colormodel, writableraster, premultiplied, properties, TYPE_CUSTOM);
|
ColorModel cm = null; boolean alpha = false; boolean premultiplied = false; switch (type) { case TYPE_4BYTE_ABGR_PRE: case TYPE_INT_ARGB_PRE: premultiplied = true; case TYPE_INT_ARGB: case TYPE_4BYTE_ABGR: alpha = true; } ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); switch (type) { case TYPE_INT_RGB: case TYPE_INT_ARGB: case TYPE_INT_ARGB_PRE: case TYPE_USHORT_565_RGB: case TYPE_USHORT_555_RGB: int[] masks = null; switch (type) { case TYPE_INT_RGB: case TYPE_INT_ARGB: case TYPE_INT_ARGB_PRE: masks = masks_int; break; case TYPE_USHORT_565_RGB: masks = masks_565; break; case TYPE_USHORT_555_RGB: masks = masks_555; break; } cm = new DirectColorModel(cs, 32, masks[0], masks[1], masks[2], alpha ? 0xff000000 : 0, premultiplied, masks[3] ); break; case TYPE_INT_BGR: String msg = "FIXME: Programmer is confused. Why (and how) does a " + "TYPE_INT_BGR image use ComponentColorModel to store " + "8-bit values? Is data type TYPE_INT or TYPE_BYTE. What " + "is the difference between TYPE_INT_BGR and TYPE_3BYTE_BGR?"; throw new UnsupportedOperationException(msg); case TYPE_3BYTE_BGR: case TYPE_4BYTE_ABGR: case TYPE_4BYTE_ABGR_PRE: case TYPE_BYTE_GRAY: case TYPE_USHORT_GRAY: int[] bits = null; int dataType = DataBuffer.TYPE_BYTE; switch (type) { case TYPE_3BYTE_BGR: bits = bits3; break; case TYPE_4BYTE_ABGR: case TYPE_4BYTE_ABGR_PRE: bits = bits4; break; case TYPE_BYTE_GRAY: bits = bits1byte; break; case TYPE_USHORT_GRAY: bits = bits1ushort; dataType = DataBuffer.TYPE_USHORT; break; } cm = new ComponentColorModel(cs, bits, alpha, premultiplied, alpha ? Transparency.TRANSLUCENT: Transparency.OPAQUE, dataType); break; case TYPE_BYTE_BINARY: byte[] vals = { 0, (byte) 0xff }; cm = new IndexColorModel(8, 2, vals, vals, vals); break; case TYPE_BYTE_INDEXED: String msg2 = "type not implemented yet"; throw new UnsupportedOperationException(msg2); } init(cm, cm.createCompatibleWritableRaster(w, h), premultiplied, null, type );
|
public BufferedImage(ColorModel colormodel, WritableRaster writableraster, boolean premultiplied, Hashtable properties) { init(colormodel, writableraster, premultiplied, properties, TYPE_CUSTOM); // TODO: perhaps try to identify type? }
|
public static void fill(float[] a, float val)
|
public static void fill(boolean[] a, boolean val)
|
public static void fill(float[] a, float val) { fill(a, 0, a.length, val); }
|
transform.concatenate(renderContext.getTransform());
|
public GNUGlyphVector(FontDelegate fontDelegate, Font font, FontRenderContext renderContext, int[] glyphs) { this.fontDelegate = fontDelegate; this.font = font; this.renderContext = renderContext; this.glyphs = glyphs; fontSize = font.getSize2D(); transform = font.getTransform(); // returns a modifiable copy transform.concatenate(renderContext.getTransform()); }
|
|
if (nameTable.getChar() != 0)
|
if (nameTable.getShort() != 0)
|
public static String getName(ByteBuffer nameTable, int name, Locale locale) { int numRecords; int macLanguage, msLanguage; int offset; int namePlatform, nameEncoding, nameLanguage, nameID, nameLen; int nameStart; String result; boolean match; if (nameTable == null) return null; nameTable.position(0); /* We understand only format 0 of the name table. */ if (nameTable.getChar() != 0) return null; macLanguage = getMacLanguageCode(locale); msLanguage = getMicrosoftLanguageCode(locale); numRecords = nameTable.getChar(); offset = nameTable.getChar(); for (int i = 0; i < numRecords; i++) { namePlatform = nameTable.getChar(); nameEncoding = nameTable.getChar(); nameLanguage = nameTable.getChar(); nameID = nameTable.getChar(); nameLen = nameTable.getChar(); nameStart = offset + nameTable.getChar(); if (nameID != name) continue; match = false; switch (namePlatform) { case PLATFORM_MACINTOSH: if ((nameLanguage == macLanguage) || (locale == null)) match = true; else { switch (macLanguage) { case 49: /* Azerbaijani/Cyrillic */ match = (nameLanguage == /* Azerbaijani/Arabic */ 50) || (nameLanguage == /* Azerbaijani/Roman */ 150); break; case 57: /* Mongolian/Mongolian */ match = (nameLanguage == /* Mongolian/Cyrillic */ 58); break; case 83: /* Malay/Roman */ match = (nameLanguage == /* Malay/Arabic */ 84); break; } } break; case PLATFORM_MICROSOFT: if (((nameLanguage & 0xff) == msLanguage) || (locale == null)) match = true; break; } if (match) { result = decodeName(namePlatform, nameEncoding, nameLanguage, nameTable, nameStart, nameLen); if (result != null) return result; } } return null; }
|
numRecords = nameTable.getChar(); offset = nameTable.getChar();
|
numRecords = nameTable.getShort(); offset = nameTable.getShort();
|
public static String getName(ByteBuffer nameTable, int name, Locale locale) { int numRecords; int macLanguage, msLanguage; int offset; int namePlatform, nameEncoding, nameLanguage, nameID, nameLen; int nameStart; String result; boolean match; if (nameTable == null) return null; nameTable.position(0); /* We understand only format 0 of the name table. */ if (nameTable.getChar() != 0) return null; macLanguage = getMacLanguageCode(locale); msLanguage = getMicrosoftLanguageCode(locale); numRecords = nameTable.getChar(); offset = nameTable.getChar(); for (int i = 0; i < numRecords; i++) { namePlatform = nameTable.getChar(); nameEncoding = nameTable.getChar(); nameLanguage = nameTable.getChar(); nameID = nameTable.getChar(); nameLen = nameTable.getChar(); nameStart = offset + nameTable.getChar(); if (nameID != name) continue; match = false; switch (namePlatform) { case PLATFORM_MACINTOSH: if ((nameLanguage == macLanguage) || (locale == null)) match = true; else { switch (macLanguage) { case 49: /* Azerbaijani/Cyrillic */ match = (nameLanguage == /* Azerbaijani/Arabic */ 50) || (nameLanguage == /* Azerbaijani/Roman */ 150); break; case 57: /* Mongolian/Mongolian */ match = (nameLanguage == /* Mongolian/Cyrillic */ 58); break; case 83: /* Malay/Roman */ match = (nameLanguage == /* Malay/Arabic */ 84); break; } } break; case PLATFORM_MICROSOFT: if (((nameLanguage & 0xff) == msLanguage) || (locale == null)) match = true; break; } if (match) { result = decodeName(namePlatform, nameEncoding, nameLanguage, nameTable, nameStart, nameLen); if (result != null) return result; } } return null; }
|
namePlatform = nameTable.getChar(); nameEncoding = nameTable.getChar(); nameLanguage = nameTable.getChar(); nameID = nameTable.getChar(); nameLen = nameTable.getChar(); nameStart = offset + nameTable.getChar();
|
namePlatform = nameTable.getShort(); nameEncoding = nameTable.getShort(); nameLanguage = nameTable.getShort(); nameID = nameTable.getShort(); nameLen = nameTable.getShort(); nameStart = offset + nameTable.getShort();
|
public static String getName(ByteBuffer nameTable, int name, Locale locale) { int numRecords; int macLanguage, msLanguage; int offset; int namePlatform, nameEncoding, nameLanguage, nameID, nameLen; int nameStart; String result; boolean match; if (nameTable == null) return null; nameTable.position(0); /* We understand only format 0 of the name table. */ if (nameTable.getChar() != 0) return null; macLanguage = getMacLanguageCode(locale); msLanguage = getMicrosoftLanguageCode(locale); numRecords = nameTable.getChar(); offset = nameTable.getChar(); for (int i = 0; i < numRecords; i++) { namePlatform = nameTable.getChar(); nameEncoding = nameTable.getChar(); nameLanguage = nameTable.getChar(); nameID = nameTable.getChar(); nameLen = nameTable.getChar(); nameStart = offset + nameTable.getChar(); if (nameID != name) continue; match = false; switch (namePlatform) { case PLATFORM_MACINTOSH: if ((nameLanguage == macLanguage) || (locale == null)) match = true; else { switch (macLanguage) { case 49: /* Azerbaijani/Cyrillic */ match = (nameLanguage == /* Azerbaijani/Arabic */ 50) || (nameLanguage == /* Azerbaijani/Roman */ 150); break; case 57: /* Mongolian/Mongolian */ match = (nameLanguage == /* Mongolian/Cyrillic */ 58); break; case 83: /* Malay/Roman */ match = (nameLanguage == /* Malay/Arabic */ 84); break; } } break; case PLATFORM_MICROSOFT: if (((nameLanguage & 0xff) == msLanguage) || (locale == null)) match = true; break; } if (match) { result = decodeName(namePlatform, nameEncoding, nameLanguage, nameTable, nameStart, nameLen); if (result != null) return result; } } return null; }
|
if ( name == NAME_POSTSCRIPT ) { if( nameTable.get(nameStart) == 0 ) result = decodeName("UTF-16BE", nameTable, nameStart, nameLen); else result = decodeName("ASCII", nameTable, nameStart, nameLen); return result; }
|
public static String getName(ByteBuffer nameTable, int name, Locale locale) { int numRecords; int macLanguage, msLanguage; int offset; int namePlatform, nameEncoding, nameLanguage, nameID, nameLen; int nameStart; String result; boolean match; if (nameTable == null) return null; nameTable.position(0); /* We understand only format 0 of the name table. */ if (nameTable.getChar() != 0) return null; macLanguage = getMacLanguageCode(locale); msLanguage = getMicrosoftLanguageCode(locale); numRecords = nameTable.getChar(); offset = nameTable.getChar(); for (int i = 0; i < numRecords; i++) { namePlatform = nameTable.getChar(); nameEncoding = nameTable.getChar(); nameLanguage = nameTable.getChar(); nameID = nameTable.getChar(); nameLen = nameTable.getChar(); nameStart = offset + nameTable.getChar(); if (nameID != name) continue; match = false; switch (namePlatform) { case PLATFORM_MACINTOSH: if ((nameLanguage == macLanguage) || (locale == null)) match = true; else { switch (macLanguage) { case 49: /* Azerbaijani/Cyrillic */ match = (nameLanguage == /* Azerbaijani/Arabic */ 50) || (nameLanguage == /* Azerbaijani/Roman */ 150); break; case 57: /* Mongolian/Mongolian */ match = (nameLanguage == /* Mongolian/Cyrillic */ 58); break; case 83: /* Malay/Roman */ match = (nameLanguage == /* Malay/Arabic */ 84); break; } } break; case PLATFORM_MICROSOFT: if (((nameLanguage & 0xff) == msLanguage) || (locale == null)) match = true; break; } if (match) { result = decodeName(namePlatform, nameEncoding, nameLanguage, nameTable, nameStart, nameLen); if (result != null) return result; } } return null; }
|
|
validCachedPreferredSize = false; tree.revalidate();
|
public void editingCanceled(ChangeEvent e) { editingPath = null; editingRow = -1; stopEditingInCompleteEditing = false; if (editingComponent != null) tree.remove(editingComponent.getParent()); editingComponent = null; if (cellEditor != null) { if (cellEditor instanceof DefaultTreeCellEditor) tree.removeTreeSelectionListener((DefaultTreeCellEditor) cellEditor); cellEditor.removeCellEditorListener(cellEditorListener); setCellEditor(null); createdCellEditor = false; } tree.requestFocusInWindow(false); editorTimer.stop(); isEditing = false; tree.repaint(); }
|
|
validCachedPreferredSize = false; tree.revalidate(); tree.repaint();
|
public void editingStopped(ChangeEvent e) { editingPath = null; editingRow = -1; stopEditingInCompleteEditing = false; if (editingComponent != null) { tree.remove(editingComponent.getParent()); editingComponent = null; } if (cellEditor != null) { newVal = ((JTextField) getCellEditor().getCellEditorValue()).getText(); completeEditing(false, false, true); if (cellEditor instanceof DefaultTreeCellEditor) tree.removeTreeSelectionListener((DefaultTreeCellEditor) cellEditor); cellEditor.removeCellEditorListener(cellEditorListener); setCellEditor(null); createdCellEditor = false; } isEditing = false; tree.requestFocusInWindow(false); editorTimer.stop(); }
|
|
if (isLeaf(row)) { bounds.x -= rightChildIndent - 4; bounds.width += rightChildIndent + 4; } else if (tree.isExpanded(path) && expandedIcon != null) bounds.width += expandedIcon.getIconWidth() + 4; else if (collapsedIcon != null) bounds.width += collapsedIcon.getIconWidth() + 4;
|
boolean isLeaf = isLeaf(row); if (isLeaf) bounds.width += rightChildIndent + gap; else if (hasControlIcons()) bounds.width += getCurrentControlIcon(path).getIconWidth() + gap;
|
public void mousePressed(MouseEvent e) { Point click = e.getPoint(); TreePath path = getClosestPathForLocation(tree, click.x, click.y); if (path != null) { bounds = getPathBounds(tree, path); int row = getRowForPath(tree, path); boolean cntlClick = isLocationInExpandControl(path, click.x, click.y); if (isLeaf(row)) { bounds.x -= rightChildIndent - 4; bounds.width += rightChildIndent + 4; } else if (tree.isExpanded(path) && expandedIcon != null) bounds.width += expandedIcon.getIconWidth() + 4; else if (collapsedIcon != null) bounds.width += collapsedIcon.getIconWidth() + 4; boolean inBounds = bounds.contains(click.x, click.y); if ((inBounds || cntlClick) && tree.isVisible(path)) { selectPath(tree, path); if (inBounds && e.getClickCount() == 2 && !isLeaf(row)) toggleExpandState(path); if (cntlClick) { handleExpandControlClick(path, click.x, click.y); if (cellEditor != null) cellEditor.cancelCellEditing(); } else if (tree.isEditable()) startEditing(path, e); } } }
|
TreePath[] paths = new TreePath[tree.getRowCount()];
|
TreePath[] paths = new TreePath[tree.getVisibleRowCount()];
|
public void actionPerformed(ActionEvent e) { TreePath lead = tree.getLeadSelectionPath(); if (e.getActionCommand().equals("selectPreviousChangeLead") || e.getActionCommand().equals("selectPreviousExtendSelection") || e.getActionCommand().equals("selectPrevious") || e.getActionCommand().equals("selectNext") || e.getActionCommand().equals("selectNextExtendSelection") || e.getActionCommand().equals("selectNextChangeLead")) (new TreeIncrementAction(0, "")).actionPerformed(e); else if (e.getActionCommand().equals("selectParent") || e.getActionCommand().equals("selectChild")) (new TreeTraverseAction(0, "")).actionPerformed(e); else if (e.getActionCommand().equals("selectAll")) { TreePath[] paths = new TreePath[tree.getRowCount()]; Object curr = getNextVisibleNode(treeModel.getRoot()); int i = 0; while (curr != null && i < paths.length) { paths[i] = new TreePath(getPathToRoot(curr, 0)); i++; } tree.addSelectionPaths(paths); } else if (e.getActionCommand().equals("startEditing")) tree.startEditingAtPath(lead); else if (e.getActionCommand().equals("toggle")) { if (tree.isEditing()) tree.stopEditing(); else { Object last = lead.getLastPathComponent(); TreePath path = new TreePath(getPathToRoot(last, 0)); if (!treeModel.isLeaf(last)) toggleExpandState(path); } } else if (e.getActionCommand().equals("clearSelection")) tree.clearSelection(); if (tree.isEditing() && !e.getActionCommand().equals("startEditing")) tree.cancelEditing(); tree.scrollPathToVisible(lead); }
|
validCachedPreferredSize = false; tree.revalidate();
|
public void treeCollapsed(TreeExpansionEvent event) { tree.repaint(); }
|
|
validCachedPreferredSize = false; tree.revalidate();
|
public void treeExpanded(TreeExpansionEvent event) { tree.repaint(); }
|
|
selectPath(tree, new TreePath(getPathToRoot(prev, 0)));
|
selectPath(tree, newPath);
|
public void actionPerformed(ActionEvent e) { Object last = tree.getLeadSelectionPath().getLastPathComponent(); if (e.getActionCommand().equals("selectPreviousChangeLead")) { Object prev = getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); selectPath(tree, new TreePath(getPathToRoot(prev, 0))); tree.setLeadSelectionPath(newPath); } } else if (e.getActionCommand().equals("selectPreviousExtendSelection")) { Object prev = getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); tree.addSelectionPath(newPath); tree.setLeadSelectionPath(newPath); } } else if (e.getActionCommand().equals("selectPrevious")) { Object prev = getPreviousVisibleNode(last); if (prev != null) { TreePath newPath = new TreePath(getPathToRoot(prev, 0)); selectPath(tree, new TreePath(getPathToRoot(prev, 0))); } } else if (e.getActionCommand().equals("selectNext")) { Object next = getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); selectPath(tree, newPath); } } else if (e.getActionCommand().equals("selectNextExtendSelection")) { Object next = getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); tree.addSelectionPath(newPath); tree.setLeadSelectionPath(newPath); } } else if (e.getActionCommand().equals("selectNextChangeLead")) { Object next = getNextVisibleNode(last); if (next != null) { TreePath newPath = new TreePath(getPathToRoot(next, 0)); selectPath(tree, newPath); tree.setLeadSelectionPath(newPath); } } }
|
validCachedPreferredSize = false; tree.revalidate();
|
public void treeNodesChanged(TreeModelEvent e) { tree.repaint(); }
|
|
validCachedPreferredSize = false; tree.revalidate();
|
public void treeNodesInserted(TreeModelEvent e) { tree.repaint(); }
|
|
validCachedPreferredSize = false; tree.revalidate();
|
public void treeNodesRemoved(TreeModelEvent e) { tree.repaint(); }
|
|
validCachedPreferredSize = false; tree.revalidate();
|
public void treeStructureChanged(TreeModelEvent e) { tree.repaint(); }
|
|
if (!treeModel.isLeaf(last) && tree.isExpanded(path)) tree.collapsePath(path);
|
if (!treeModel.isLeaf(last)) toggleExpandState(path);
|
public void actionPerformed(ActionEvent e) { Object last = tree.getLeadSelectionPath().getLastPathComponent(); if (e.getActionCommand().equals("selectParent")) { TreePath path = new TreePath(getPathToRoot(last, 0)); Object p = getParent(treeModel.getRoot(), last); if (!treeModel.isLeaf(last) && tree.isExpanded(path)) tree.collapsePath(path); else if (p != null) selectPath(tree, new TreePath(getPathToRoot(p, 0))); } else if (e.getActionCommand().equals("selectChild")) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!treeModel.isLeaf(last) && tree.isCollapsed(path)) tree.expandPath(path); else { Object next = getNextVisibleNode(last); if (next != null) selectPath(tree, new TreePath(getPathToRoot(next, 0))); } } }
|
if (!treeModel.isLeaf(last) && tree.isCollapsed(path)) tree.expandPath(path);
|
if (!treeModel.isLeaf(last)) toggleExpandState(path);
|
public void actionPerformed(ActionEvent e) { Object last = tree.getLeadSelectionPath().getLastPathComponent(); if (e.getActionCommand().equals("selectParent")) { TreePath path = new TreePath(getPathToRoot(last, 0)); Object p = getParent(treeModel.getRoot(), last); if (!treeModel.isLeaf(last) && tree.isExpanded(path)) tree.collapsePath(path); else if (p != null) selectPath(tree, new TreePath(getPathToRoot(p, 0))); } else if (e.getActionCommand().equals("selectChild")) { TreePath path = new TreePath(getPathToRoot(last, 0)); if (!treeModel.isLeaf(last) && tree.isCollapsed(path)) tree.expandPath(path); else { Object next = getNextVisibleNode(last); if (next != null) selectPath(tree, new TreePath(getPathToRoot(next, 0))); } } }
|
leafIcon = UIManager.getIcon("Tree.leafIcon");
|
public BasicTreeUI() { drawingCache = new Hashtable(); nodeDimensions = createNodeDimensions(); configureLayoutCache(); propertyChangeListener = createPropertyChangeListener(); focusListener = createFocusListener(); treeSelectionListener = createTreeSelectionListener(); mouseInputListener = new MouseInputHandler(null, null, null); keyListener = createKeyListener(); selectionModelPropertyChangeListener = createSelectionModelPropertyChangeListener(); componentListener = createComponentListener(); cellEditorListener = createCellEditorListener(); treeExpansionListener = createTreeExpansionListener(); treeModelListener = createTreeModelListener(); editingRow = -1; lastSelectedRow = -1; }
|
|
return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s) + 4,
|
return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s) + gap,
|
Rectangle getCellBounds(int x, int y, Object cell) { if (cell != null) { String s = cell.toString(); Font f = tree.getFont(); FontMetrics fm = tree.getToolkit().getFontMetrics(f); if (s != null) return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s) + 4, fm.getHeight()); } return new Rectangle(x, y, 0, 0); }
|
if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((getLevel(node)) * rightChildIndent), y); return new Point(x + ((getLevel(node) + 1) * rightChildIndent), y);
|
int level = getLevel(node); if (level == 0) return new Point(x, y); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((level - 1) * rightChildIndent), y); return new Point(x + (level * rightChildIndent), y);
|
Point getCellLocation(int x, int y, JTree tree, TreeModel mod, Object node, Object startNode) { int rowHeight = getRowHeight(); if (startNode == null || startNode.equals(node)) { if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((getLevel(node)) * rightChildIndent), y); return new Point(x + ((getLevel(node) + 1) * rightChildIndent), y); } if (!mod.isLeaf(startNode) && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0))) && !mod.isLeaf(startNode) && mod.getChildCount(startNode) > 0) { Object child = mod.getChild(startNode, 0); if (child != null) return getCellLocation(x, y + rowHeight, tree, mod, node, child); } return getCellLocation(x, y + rowHeight, tree, mod, node, getNextVisibleNode(startNode)); }
|
if (!mod.isLeaf(startNode) && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0))) && !mod.isLeaf(startNode) && mod.getChildCount(startNode) > 0) { Object child = mod.getChild(startNode, 0); if (child != null) return getCellLocation(x, y + rowHeight, tree, mod, node, child); }
|
Point getCellLocation(int x, int y, JTree tree, TreeModel mod, Object node, Object startNode) { int rowHeight = getRowHeight(); if (startNode == null || startNode.equals(node)) { if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) return new Point(x + ((getLevel(node)) * rightChildIndent), y); return new Point(x + ((getLevel(node) + 1) * rightChildIndent), y); } if (!mod.isLeaf(startNode) && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0))) && !mod.isLeaf(startNode) && mod.getChildCount(startNode) > 0) { Object child = mod.getChild(startNode, 0); if (child != null) return getCellLocation(x, y + rowHeight, tree, mod, node, child); } return getCellLocation(x, y + rowHeight, tree, mod, node, getNextVisibleNode(startNode)); }
|
|
Object next = null; TreePath current = null; if (node != null) next = getNextNode(node); if (next != null)
|
if (currentVisiblePath != null)
|
Object getNextVisibleNode(Object node) { Object next = null; TreePath current = null; if (node != null) next = getNextNode(node); if (next != null) { current = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(current)) return next; while (next != null && !tree.isVisible(current)) { next = getNextNode(next); if (next != null) current = new TreePath(getPathToRoot(next, 0)); } } return next; }
|
current = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(current)) return next; while (next != null && !tree.isVisible(current)) { next = getNextNode(next); if (next != null) current = new TreePath(getPathToRoot(next, 0)); }
|
Object[] nodes = currentVisiblePath.getPath(); int i = 0; while (i < nodes.length && !node.equals(nodes[i])) i++; if (i+1 < nodes.length) return nodes[i+1];
|
Object getNextVisibleNode(Object node) { Object next = null; TreePath current = null; if (node != null) next = getNextNode(node); if (next != null) { current = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(current)) return next; while (next != null && !tree.isVisible(current)) { next = getNextNode(next); if (next != null) current = new TreePath(getPathToRoot(next, 0)); } } return next; }
|
return next;
|
return null;
|
Object getNextVisibleNode(Object node) { Object next = null; TreePath current = null; if (node != null) next = getNextNode(node); if (next != null) { current = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(current)) return next; while (next != null && !tree.isVisible(current)) { next = getNextNode(next); if (next != null) current = new TreePath(getPathToRoot(next, 0)); } } return next; }
|
if (treeModel != null)
|
if (treeModel != null && currentVisiblePath != null)
|
public TreePath getPathForRow(JTree tree, int row) { if (treeModel != null) { Object node = treeModel.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(getPathToRoot(node, 0)))) node = getNextNode(node); for (int i = 0; i < row; i++) node = getNextVisibleNode(node); if (node == null) return null; return new TreePath(getPathToRoot(node, 0)); } return null; }
|
Object node = treeModel.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(getPathToRoot(node, 0)))) node = getNextNode(node); for (int i = 0; i < row; i++) node = getNextVisibleNode(node); if (node == null) return null; return new TreePath(getPathToRoot(node, 0));
|
Object[] nodes = currentVisiblePath.getPath(); if (row < nodes.length) return new TreePath(getPathToRoot(nodes[row], 0));
|
public TreePath getPathForRow(JTree tree, int row) { if (treeModel != null) { Object node = treeModel.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(getPathToRoot(node, 0)))) node = getNextNode(node); for (int i = 0; i < row; i++) node = getNextVisibleNode(node); if (node == null) return null; return new TreePath(getPathToRoot(node, 0)); } return null; }
|
return null;
|
return preferredMinSize;
|
public Dimension getPreferredMinSize() { // FIXME: not implemented return null; }
|
Object prev = null; TreePath current = null; if (node != null) prev = getPreviousNode(node); if (prev != null) { current = new TreePath(getPathToRoot(prev, 0)); if (tree.isVisible(current)) return prev; while (prev != null && !tree.isVisible(current))
|
if (currentVisiblePath != null)
|
Object getPreviousVisibleNode(Object node) { Object prev = null; TreePath current = null; if (node != null) prev = getPreviousNode(node); if (prev != null) { current = new TreePath(getPathToRoot(prev, 0)); if (tree.isVisible(current)) return prev; while (prev != null && !tree.isVisible(current)) { prev = getPreviousNode(prev); if (prev != null) current = new TreePath(getPathToRoot(prev, 0)); } } return prev; }
|
prev = getPreviousNode(prev); if (prev != null) current = new TreePath(getPathToRoot(prev, 0)); }
|
Object[] nodes = currentVisiblePath.getPath(); int i = 0; while (i < nodes.length && !node.equals(nodes[i])) i++; if (i-1 > 0) return nodes[i-1];
|
Object getPreviousVisibleNode(Object node) { Object prev = null; TreePath current = null; if (node != null) prev = getPreviousNode(node); if (prev != null) { current = new TreePath(getPathToRoot(prev, 0)); if (tree.isVisible(current)) return prev; while (prev != null && !tree.isVisible(current)) { prev = getPreviousNode(prev); if (prev != null) current = new TreePath(getPathToRoot(prev, 0)); } } return prev; }
|
return prev;
|
return null;
|
Object getPreviousVisibleNode(Object node) { Object prev = null; TreePath current = null; if (node != null) prev = getPreviousNode(node); if (prev != null) { current = new TreePath(getPathToRoot(prev, 0)); if (tree.isVisible(current)) return prev; while (prev != null && !tree.isVisible(current)) { prev = getPreviousNode(prev); if (prev != null) current = new TreePath(getPathToRoot(prev, 0)); } } return prev; }
|
int count = 0; if (treeModel != null) { Object node = treeModel.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath((getPathToRoot(node, 0))))) node = getNextNode(node); while (node != null) { count++; node = getNextVisibleNode(node); } } return count;
|
if (currentVisiblePath != null) return currentVisiblePath.getPathCount(); return 0;
|
public int getRowCount(JTree tree) { int count = 0; if (treeModel != null) { Object node = treeModel.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath((getPathToRoot(node, 0))))) node = getNextNode(node); while (node != null) { count++; node = getNextVisibleNode(node); } } return count; }
|
Object curr = treeModel.getRoot(); while (curr != null && !curr.equals(dest))
|
int rowCount = getRowCount(tree); if (currentVisiblePath != null)
|
public int getRowForPath(JTree tree, TreePath path) { int row = 0; Object dest = path.getLastPathComponent(); Object curr = treeModel.getRoot(); while (curr != null && !curr.equals(dest)) { ++row; curr = getNextVisibleNode(curr); } return row; }
|
++row; curr = getNextVisibleNode(curr);
|
Object[] nodes = currentVisiblePath.getPath(); while (row < rowCount) { if (dest.equals(nodes[row])) return row; row++; }
|
public int getRowForPath(JTree tree, TreePath path) { int row = 0; Object dest = path.getLastPathComponent(); Object curr = treeModel.getRoot(); while (curr != null && !curr.equals(dest)) { ++row; curr = getNextVisibleNode(curr); } return row; }
|
return row;
|
return -1;
|
public int getRowForPath(JTree tree, TreePath path) { int row = 0; Object dest = path.getLastPathComponent(); Object curr = treeModel.getRoot(); while (curr != null && !curr.equals(dest)) { ++row; curr = getNextVisibleNode(curr); } return row; }
|
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); tree.setFont(defaults.getFont("Tree.font")); tree.setForeground(defaults.getColor("Tree.foreground")); tree.setBackground(defaults.getColor("Tree.background"));
|
LookAndFeel.installColorsAndFont(tree, "Tree.background", "Tree.foreground", "Tree.font");
|
protected void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); tree.setFont(defaults.getFont("Tree.font")); tree.setForeground(defaults.getColor("Tree.foreground")); tree.setBackground(defaults.getColor("Tree.background")); tree.setOpaque(true); rightChildIndent = defaults.getInt("Tree.rightChildIndent"); leftChildIndent = defaults.getInt("Tree.leftChildIndent"); setRowHeight(defaults.getInt("Tree.rowHeight")); tree.requestFocusInWindow(false); tree.setScrollsOnExpand(defaults.getBoolean("Tree.scrollsOnExpand")); setExpandedIcon(defaults.getIcon("Tree.expandedIcon")); setCollapsedIcon(defaults.getIcon("Tree.collapsedIcon")); }
|
rightChildIndent = defaults.getInt("Tree.rightChildIndent"); leftChildIndent = defaults.getInt("Tree.leftChildIndent"); setRowHeight(defaults.getInt("Tree.rowHeight"));
|
rightChildIndent = UIManager.getInt("Tree.rightChildIndent"); leftChildIndent = UIManager.getInt("Tree.leftChildIndent"); setRowHeight(UIManager.getInt("Tree.rowHeight"));
|
protected void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); tree.setFont(defaults.getFont("Tree.font")); tree.setForeground(defaults.getColor("Tree.foreground")); tree.setBackground(defaults.getColor("Tree.background")); tree.setOpaque(true); rightChildIndent = defaults.getInt("Tree.rightChildIndent"); leftChildIndent = defaults.getInt("Tree.leftChildIndent"); setRowHeight(defaults.getInt("Tree.rowHeight")); tree.requestFocusInWindow(false); tree.setScrollsOnExpand(defaults.getBoolean("Tree.scrollsOnExpand")); setExpandedIcon(defaults.getIcon("Tree.expandedIcon")); setCollapsedIcon(defaults.getIcon("Tree.collapsedIcon")); }
|
tree.setScrollsOnExpand(defaults.getBoolean("Tree.scrollsOnExpand")); setExpandedIcon(defaults.getIcon("Tree.expandedIcon")); setCollapsedIcon(defaults.getIcon("Tree.collapsedIcon"));
|
tree.setScrollsOnExpand(UIManager.getBoolean("Tree.scrollsOnExpand")); setExpandedIcon(UIManager.getIcon("Tree.openIcon")); setCollapsedIcon(UIManager.getIcon("Tree.closedIcon"));
|
protected void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); tree.setFont(defaults.getFont("Tree.font")); tree.setForeground(defaults.getColor("Tree.foreground")); tree.setBackground(defaults.getColor("Tree.background")); tree.setOpaque(true); rightChildIndent = defaults.getInt("Tree.rightChildIndent"); leftChildIndent = defaults.getInt("Tree.leftChildIndent"); setRowHeight(defaults.getInt("Tree.rowHeight")); tree.requestFocusInWindow(false); tree.setScrollsOnExpand(defaults.getBoolean("Tree.scrollsOnExpand")); setExpandedIcon(defaults.getIcon("Tree.expandedIcon")); setCollapsedIcon(defaults.getIcon("Tree.collapsedIcon")); }
|
tree = (JTree) c;
|
public void installUI(JComponent c) { prepareForUIInstall(); super.installUI(c); tree = (JTree) c; installDefaults(); installComponents(); setCellEditor(createDefaultCellEditor()); createdCellEditor = true; isEditing = false; TreeModel mod = tree.getModel(); setModel(mod); if (mod != null) tree.expandPath(new TreePath(mod.getRoot())); treeSelectionModel = tree.getSelectionModel(); installKeyboardActions(); installListeners(); completeUIInstall(); }
|
|
tree.expandPath(new TreePath(mod.getRoot()));
|
{ TreePath path = new TreePath(mod.getRoot()); if (!tree.isExpanded(path)) toggleExpandState(path); }
|
public void installUI(JComponent c) { prepareForUIInstall(); super.installUI(c); tree = (JTree) c; installDefaults(); installComponents(); setCellEditor(createDefaultCellEditor()); createdCellEditor = true; isEditing = false; TreeModel mod = tree.getModel(); setModel(mod); if (mod != null) tree.expandPath(new TreePath(mod.getRoot())); treeSelectionModel = tree.getSelectionModel(); installKeyboardActions(); installListeners(); completeUIInstall(); }
|
if (tree.isExpanded(path) && expandedIcon != null) bounds.x -= expandedIcon.getIconWidth() - 4; else if (collapsedIcon != null) bounds.x -= collapsedIcon.getIconWidth() - 4;
|
protected boolean isLocationInExpandControl(TreePath path, int mouseX, int mouseY) { boolean cntlClick = false; int row = getRowForPath(tree, path); if (!isLeaf(row)) { if (bounds == null) bounds = getPathBounds(tree, path); if (tree.isExpanded(path) && expandedIcon != null) bounds.x -= expandedIcon.getIconWidth() - 4; else if (collapsedIcon != null) bounds.x -= collapsedIcon.getIconWidth() - 4; Icon controlIcon = getCurrentControlIcon(path); if (controlIcon != null && (mouseX < bounds.x) && (mouseX > (bounds.x - controlIcon.getIconWidth()))) cntlClick = true; } return cntlClick; }
|
|
Icon controlIcon = getCurrentControlIcon(path); if (controlIcon != null && (mouseX < bounds.x) && (mouseX > (bounds.x - controlIcon.getIconWidth())))
|
if (hasControlIcons() && (mouseX < bounds.x) && (mouseX > (bounds.x - getCurrentControlIcon(path).getIconWidth())))
|
protected boolean isLocationInExpandControl(TreePath path, int mouseX, int mouseY) { boolean cntlClick = false; int row = getRowForPath(tree, path); if (!isLeaf(row)) { if (bounds == null) bounds = getPathBounds(tree, path); if (tree.isExpanded(path) && expandedIcon != null) bounds.x -= expandedIcon.getIconWidth() - 4; else if (collapsedIcon != null) bounds.x -= collapsedIcon.getIconWidth() - 4; Icon controlIcon = getCurrentControlIcon(path); if (controlIcon != null && (mouseX < bounds.x) && (mouseX > (bounds.x - controlIcon.getIconWidth()))) cntlClick = true; } return cntlClick; }
|
paintRecursive(g, 0, 0, 0, 0, tree, treeModel, root);
|
paintRecursive(g, 0, 0, 0, tree, treeModel, root);
|
public void paint(Graphics g, JComponent c) { JTree tree = (JTree) c; if (treeModel != null) { Object root = treeModel.getRoot(); paintRecursive(g, 0, 0, 0, 0, tree, treeModel, root); if (hasControlIcons()) paintControlIcons(g, 0, 0, 0, 0, tree, treeModel, root); } }
|
if (!node.equals(mod.getRoot()))
|
if (!node.equals(mod.getRoot()) && (tree.isRootVisible() || getLevel(node) != 1))
|
int paintControlIcons(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object node) { int h = descent; int rowHeight = getRowHeight(); TreePath path = new TreePath(getPathToRoot(node, 0)); Icon icon = getCurrentControlIcon(path); Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; if (mod.isLeaf(node)) descent += rowHeight; else { if (depth > 0 || tree.isRootVisible()) descent += rowHeight; int max = 0; if (!mod.isLeaf(node)) max = mod.getChildCount(node); if (!node.equals(mod.getRoot())) icon.paintIcon(tree, g, indentation - rightChildIndent - 3, h); if (tree.isExpanded(path)) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (depth == 0 && !tree.isRootVisible()) indent = -1; descent = paintControlIcons(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(node, i)); } } } return descent; }
|
indent = -1;
|
indent = 1;
|
int paintControlIcons(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object node) { int h = descent; int rowHeight = getRowHeight(); TreePath path = new TreePath(getPathToRoot(node, 0)); Icon icon = getCurrentControlIcon(path); Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; if (mod.isLeaf(node)) descent += rowHeight; else { if (depth > 0 || tree.isRootVisible()) descent += rowHeight; int max = 0; if (!mod.isLeaf(node)) max = mod.getChildCount(node); if (!node.equals(mod.getRoot())) icon.paintIcon(tree, g, indentation - rightChildIndent - 3, h); if (tree.isExpanded(path)) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (depth == 0 && !tree.isRootVisible()) indent = -1; descent = paintControlIcons(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(node, i)); } } } return descent; }
|
if (treeModel != null)
|
if (treeModel != null && hasControlIcons())
|
protected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { if (treeModel != null) paintControlIcons(g, 0, 0, 0, 0, tree, treeModel, path.getLastPathComponent()); }
|
int paintRecursive(Graphics g, int indentation, int descent, int childNumber,
|
int paintRecursive(Graphics g, int indentation, int descent,
|
int paintRecursive(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object curr) { Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; boolean isRootVisible = tree.isRootVisible(); if (mod.isLeaf(curr)) { paintNode(g, indentation + 4, descent, tree, curr, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintNode(g, indentation + 4, descent, tree, curr, false); descent += getRowHeight(); y0 += halfHeight; } int max = 0; if (!mod.isLeaf(curr)) max = mod.getChildCount(curr); if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if ((!isRootVisible && !curr.equals(mod.getRoot())) || isRootVisible) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) if (y0 != heightOfLine && !mod.isLeaf(curr) && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; }
|
if (mod.isLeaf(curr))
|
if (isLeaf)
|
int paintRecursive(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object curr) { Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; boolean isRootVisible = tree.isRootVisible(); if (mod.isLeaf(curr)) { paintNode(g, indentation + 4, descent, tree, curr, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintNode(g, indentation + 4, descent, tree, curr, false); descent += getRowHeight(); y0 += halfHeight; } int max = 0; if (!mod.isLeaf(curr)) max = mod.getChildCount(curr); if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if ((!isRootVisible && !curr.equals(mod.getRoot())) || isRootVisible) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) if (y0 != heightOfLine && !mod.isLeaf(curr) && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; }
|
paintNode(g, indentation + 4, descent, tree, curr, true);
|
paintRow(g, clip, null, bounds, path, row, true, false, true);
|
int paintRecursive(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object curr) { Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; boolean isRootVisible = tree.isRootVisible(); if (mod.isLeaf(curr)) { paintNode(g, indentation + 4, descent, tree, curr, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintNode(g, indentation + 4, descent, tree, curr, false); descent += getRowHeight(); y0 += halfHeight; } int max = 0; if (!mod.isLeaf(curr)) max = mod.getChildCount(curr); if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if ((!isRootVisible && !curr.equals(mod.getRoot())) || isRootVisible) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) if (y0 != heightOfLine && !mod.isLeaf(curr) && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; }
|
paintNode(g, indentation + 4, descent, tree, curr, false);
|
paintRow(g, clip, null, bounds, path, row, isExpanded, false, false);
|
int paintRecursive(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object curr) { Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; boolean isRootVisible = tree.isRootVisible(); if (mod.isLeaf(curr)) { paintNode(g, indentation + 4, descent, tree, curr, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintNode(g, indentation + 4, descent, tree, curr, false); descent += getRowHeight(); y0 += halfHeight; } int max = 0; if (!mod.isLeaf(curr)) max = mod.getChildCount(curr); if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if ((!isRootVisible && !curr.equals(mod.getRoot())) || isRootVisible) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) if (y0 != heightOfLine && !mod.isLeaf(curr) && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; }
|
int max = 0; if (!mod.isLeaf(curr)) max = mod.getChildCount(curr); if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0))))
|
int max = mod.getChildCount(curr); if (isExpanded)
|
int paintRecursive(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object curr) { Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; boolean isRootVisible = tree.isRootVisible(); if (mod.isLeaf(curr)) { paintNode(g, indentation + 4, descent, tree, curr, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintNode(g, indentation + 4, descent, tree, curr, false); descent += getRowHeight(); y0 += halfHeight; } int max = 0; if (!mod.isLeaf(curr)) max = mod.getChildCount(curr); if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if ((!isRootVisible && !curr.equals(mod.getRoot())) || isRootVisible) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) if (y0 != heightOfLine && !mod.isLeaf(curr) && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; }
|
else if ((!isRootVisible && !curr.equals(mod.getRoot())) || isRootVisible)
|
else if (isRootVisible || (!isRootVisible && !curr.equals(root)))
|
int paintRecursive(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object curr) { Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; boolean isRootVisible = tree.isRootVisible(); if (mod.isLeaf(curr)) { paintNode(g, indentation + 4, descent, tree, curr, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintNode(g, indentation + 4, descent, tree, curr, false); descent += getRowHeight(); y0 += halfHeight; } int max = 0; if (!mod.isLeaf(curr)) max = mod.getChildCount(curr); if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if ((!isRootVisible && !curr.equals(mod.getRoot())) || isRootVisible) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) if (y0 != heightOfLine && !mod.isLeaf(curr) && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; }
|
descent = paintRecursive(g, indent, descent, i, depth + 1,
|
descent = paintRecursive(g, indent, descent, depth + 1,
|
int paintRecursive(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object curr) { Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; boolean isRootVisible = tree.isRootVisible(); if (mod.isLeaf(curr)) { paintNode(g, indentation + 4, descent, tree, curr, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintNode(g, indentation + 4, descent, tree, curr, false); descent += getRowHeight(); y0 += halfHeight; } int max = 0; if (!mod.isLeaf(curr)) max = mod.getChildCount(curr); if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if ((!isRootVisible && !curr.equals(mod.getRoot())) || isRootVisible) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) if (y0 != heightOfLine && !mod.isLeaf(curr) && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; }
|
if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) if (y0 != heightOfLine && !mod.isLeaf(curr)
|
if (isExpanded) if (y0 != heightOfLine && !isLeaf
|
int paintRecursive(Graphics g, int indentation, int descent, int childNumber, int depth, JTree tree, TreeModel mod, Object curr) { Rectangle clip = tree.getVisibleRect(); if (indentation > clip.x + clip.width + rightChildIndent || descent > clip.y + clip.height + getRowHeight()) return descent; int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; boolean isRootVisible = tree.isRootVisible(); if (mod.isLeaf(curr)) { paintNode(g, indentation + 4, descent, tree, curr, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintNode(g, indentation + 4, descent, tree, curr, false); descent += getRowHeight(); y0 += halfHeight; } int max = 0; if (!mod.isLeaf(curr)) max = mod.getChildCount(curr); if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) { for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if ((!isRootVisible && !curr.equals(mod.getRoot())) || isRootVisible) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, i, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0)))) if (y0 != heightOfLine && !mod.isLeaf(curr) && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; }
|
boolean selected = tree.isPathSelected(path); boolean hasIcons = false; Object node = path.getLastPathComponent(); if (tree.isVisible(path)) { if (editingComponent != null && editingPath != null && isEditing(tree) && node.equals(editingPath.getLastPathComponent())) { rendererPane.paintComponent(g, editingComponent.getParent(), null, bounds); } else { TreeCellRenderer dtcr = tree.getCellRenderer(); if (dtcr == null) dtcr = createDefaultCellRenderer(); Component c = dtcr.getTreeCellRendererComponent(tree, node, selected, isExpanded, isLeaf, row, false); bounds.x += gap; rendererPane.paintComponent(g, c, c.getParent(), bounds); } }
|
protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { // FIXME: not implemented. }
|
|
validCachedPreferredSize = false; tree.revalidate(); tree.repaint();
|
protected void pathWasCollapsed(TreePath path) { // FIXME: not implemented }
|
|
validCachedPreferredSize = false; tree.revalidate(); tree.repaint();
|
protected void pathWasExpanded(TreePath path) { // FIXME: not implemented }
|
|
preferredMinSize = newSize;
|
public void setPreferredMinSize(Dimension newSize) { // FIXME: not implemented }
|
|
Object node = path.getLastPathComponent(); if (treeModel != null && (!isLeaf && !node.equals(treeModel.getRoot())) && (tree.isRootVisible() || getLevel(node) != 1)) return true;
|
protected boolean shouldPaintExpandControl(TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { // FIXME: not implemented. return false; }
|
|
Rectangle bounds = getPathBounds(tree, path);
|
bounds = getPathBounds(tree, path);
|
protected boolean startEditing(TreePath path, MouseEvent event) { int x; int y; if (event == null) { Rectangle bounds = getPathBounds(tree, path); x = bounds.x; y = bounds.y; } else { x = event.getX(); y = event.getY(); } updateCellEditor(); TreeCellEditor ed = getCellEditor(); if (ed != null && ed.shouldSelectCell(event) && ed.isCellEditable(event)) { editingPath = path; editingRow = tree.getRowForPath(editingPath); Object val = editingPath.getLastPathComponent(); cellEditor.addCellEditorListener(cellEditorListener); stopEditingInCompleteEditing = false; boolean expanded = tree.isExpanded(editingPath); isEditing = true; editingComponent = ed.getTreeCellEditorComponent(tree, val, true, expanded, isLeaf(editingRow), editingRow); editingComponent.getParent().setVisible(true); editingComponent.getParent().validate(); tree.add(editingComponent.getParent()); editingComponent.getParent().validate(); ((JTextField) editingComponent).requestFocusInWindow(false); editorTimer.start(); return true; } return false; }
|
validCachedPreferredSize = false; tree.revalidate();
|
protected boolean startEditing(TreePath path, MouseEvent event) { int x; int y; if (event == null) { Rectangle bounds = getPathBounds(tree, path); x = bounds.x; y = bounds.y; } else { x = event.getX(); y = event.getY(); } updateCellEditor(); TreeCellEditor ed = getCellEditor(); if (ed != null && ed.shouldSelectCell(event) && ed.isCellEditable(event)) { editingPath = path; editingRow = tree.getRowForPath(editingPath); Object val = editingPath.getLastPathComponent(); cellEditor.addCellEditorListener(cellEditorListener); stopEditingInCompleteEditing = false; boolean expanded = tree.isExpanded(editingPath); isEditing = true; editingComponent = ed.getTreeCellEditorComponent(tree, val, true, expanded, isLeaf(editingRow), editingRow); editingComponent.getParent().setVisible(true); editingComponent.getParent().validate(); tree.add(editingComponent.getParent()); editingComponent.getParent().validate(); ((JTextField) editingComponent).requestFocusInWindow(false); editorTimer.start(); return true; } return false; }
|
|
updateCurrentVisiblePath();
|
protected void toggleExpandState(TreePath path) { if (tree.isExpanded(path)) tree.collapsePath(path); else tree.expandPath(path); }
|
|
int maxWidth = 0; boolean isLeaf = false; if (currentVisiblePath != null) { Object[] path = currentVisiblePath.getPath(); for (int i = 0; i < path.length; i++) { TreePath curr = new TreePath(getPathToRoot(path[i], 0)); Rectangle bounds = getPathBounds(tree, curr); if (treeModel != null) isLeaf = treeModel.isLeaf(path[i]); if (!isLeaf && hasControlIcons()) bounds.width += getCurrentControlIcon(curr).getIconWidth(); maxWidth = Math.max(maxWidth, bounds.x + bounds.width); } preferredSize = new Dimension(maxWidth, (getRowHeight() * path.length)); } else preferredSize = new Dimension(0, 0); validCachedPreferredSize = true;
|
protected void updateCachedPreferredSize() { // FIXME: not implemented }
|
|
updateExpandedDescendants(new TreePath(getPathToRoot(treeModel. getRoot(), 0)));
|
updateExpandedDescendants(new TreePath(treeModel.getRoot()));
|
protected void updateLayoutCacheExpandedNodes() { if (treeModel != null) updateExpandedDescendants(new TreePath(getPathToRoot(treeModel. getRoot(), 0))); }
|
} }
|
protected void updateRenderer() { if (tree != null) tree.setCellRenderer(currentCellRenderer); }
|
|
String id; String kind; String next;
|
public NameComponent[] toName(String a_name) throws InvalidName { ArrayList components = new ArrayList(); StringTokenizer st = new StringTokenizer(a_name, "./\\", true); String id; String kind; String next; // Create the buffer array, reserving the last element for null. String[] n = new String[ st.countTokens() + 1 ]; int pp = 0; while (st.hasMoreTokens()) n [ pp++ ] = st.nextToken(); IntHolder p = new IntHolder(); NameComponent node = readNode(p, n); while (node != null) { components.add(node); node = readNode(p, n); } NameComponent[] name = new NameComponent[ components.size() ]; for (int i = 0; i < name.length; i++) { name [ i ] = (NameComponent) components.get(i); } NameValidator.check(name); return name; }
|
|
public InvalidName(String why)
|
public InvalidName()
|
public InvalidName(String why) { super(why); }
|
super(why);
|
public InvalidName(String why) { super(why); }
|
|
public NameComponent(String _id, String _kind)
|
public NameComponent()
|
public NameComponent(String _id, String _kind) { id = _id; kind = _kind; }
|
id = _id; kind = _kind;
|
public NameComponent(String _id, String _kind) { id = _id; kind = _kind; }
|
|
private StyleConstants(String k)
|
StyleConstants(String k)
|
private StyleConstants(String k) { keyname = k; }
|
public static double getFlatnessSq(double[] coords, int offset)
|
public static double getFlatnessSq(double x1, double y1, double cx1, double cy1, double cx2, double cy2, double x2, double y2)
|
public static double getFlatnessSq(double[] coords, int offset) { return getFlatnessSq(coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++]); }
|
return getFlatnessSq(coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++]);
|
return Math.max(Line2D.ptSegDistSq(x1, y1, x2, y2, cx1, cy1), Line2D.ptSegDistSq(x1, y1, x2, y2, cx2, cy2));
|
public static double getFlatnessSq(double[] coords, int offset) { return getFlatnessSq(coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++]); }
|
public static double getFlatnessSq(double[] coords, int offset)
|
public static double getFlatnessSq(double x1, double y1, double cx, double cy, double x2, double y2)
|
public static double getFlatnessSq(double[] coords, int offset) { return Line2D.ptSegDistSq(coords[offset], coords[offset + 1], coords[offset + 4], coords[offset + 5], coords[offset + 2], coords[offset + 3]); }
|
return Line2D.ptSegDistSq(coords[offset], coords[offset + 1], coords[offset + 4], coords[offset + 5], coords[offset + 2], coords[offset + 3]);
|
return Line2D.ptSegDistSq(x1, y1, x2, y2, cx, cy);
|
public static double getFlatnessSq(double[] coords, int offset) { return Line2D.ptSegDistSq(coords[offset], coords[offset + 1], coords[offset + 4], coords[offset + 5], coords[offset + 2], coords[offset + 3]); }
|
public static void subdivide(double[] src, int srcOff, double[] left, int leftOff, double[] right, int rightOff)
|
public void subdivide(QuadCurve2D left, QuadCurve2D right)
|
public static void subdivide(double[] src, int srcOff, double[] left, int leftOff, double[] right, int rightOff) { double x1; double y1; double xc; double yc; double x2; double y2; x1 = src[srcOff]; y1 = src[srcOff + 1]; xc = src[srcOff + 2]; yc = src[srcOff + 3]; x2 = src[srcOff + 4]; y2 = src[srcOff + 5]; if (left != null) { left[leftOff] = x1; left[leftOff + 1] = y1; } if (right != null) { right[rightOff + 4] = x2; right[rightOff + 5] = y2; } x1 = (x1 + xc) / 2; x2 = (xc + x2) / 2; xc = (x1 + x2) / 2; y1 = (y1 + yc) / 2; y2 = (y2 + yc) / 2; yc = (y1 + y2) / 2; if (left != null) { left[leftOff + 2] = x1; left[leftOff + 3] = y1; left[leftOff + 4] = xc; left[leftOff + 5] = yc; } if (right != null) { right[rightOff] = xc; right[rightOff + 1] = yc; right[rightOff + 2] = x2; right[rightOff + 3] = y2; } }
|
double x1; double y1; double xc; double yc; double x2; double y2; x1 = src[srcOff]; y1 = src[srcOff + 1]; xc = src[srcOff + 2]; yc = src[srcOff + 3]; x2 = src[srcOff + 4]; y2 = src[srcOff + 5];
|
double[] d = new double[] { getX1(), getY1(), getCtrlX(), getCtrlY(), getX2(), getY2(), 0, 0, 0, 0 }; subdivide(d, 0, d, 0, d, 4);
|
public static void subdivide(double[] src, int srcOff, double[] left, int leftOff, double[] right, int rightOff) { double x1; double y1; double xc; double yc; double x2; double y2; x1 = src[srcOff]; y1 = src[srcOff + 1]; xc = src[srcOff + 2]; yc = src[srcOff + 3]; x2 = src[srcOff + 4]; y2 = src[srcOff + 5]; if (left != null) { left[leftOff] = x1; left[leftOff + 1] = y1; } if (right != null) { right[rightOff + 4] = x2; right[rightOff + 5] = y2; } x1 = (x1 + xc) / 2; x2 = (xc + x2) / 2; xc = (x1 + x2) / 2; y1 = (y1 + yc) / 2; y2 = (y2 + yc) / 2; yc = (y1 + y2) / 2; if (left != null) { left[leftOff + 2] = x1; left[leftOff + 3] = y1; left[leftOff + 4] = xc; left[leftOff + 5] = yc; } if (right != null) { right[rightOff] = xc; right[rightOff + 1] = yc; right[rightOff + 2] = x2; right[rightOff + 3] = y2; } }
|
{ left[leftOff] = x1; left[leftOff + 1] = y1; }
|
left.setCurve(d, 0);
|
public static void subdivide(double[] src, int srcOff, double[] left, int leftOff, double[] right, int rightOff) { double x1; double y1; double xc; double yc; double x2; double y2; x1 = src[srcOff]; y1 = src[srcOff + 1]; xc = src[srcOff + 2]; yc = src[srcOff + 3]; x2 = src[srcOff + 4]; y2 = src[srcOff + 5]; if (left != null) { left[leftOff] = x1; left[leftOff + 1] = y1; } if (right != null) { right[rightOff + 4] = x2; right[rightOff + 5] = y2; } x1 = (x1 + xc) / 2; x2 = (xc + x2) / 2; xc = (x1 + x2) / 2; y1 = (y1 + yc) / 2; y2 = (y2 + yc) / 2; yc = (y1 + y2) / 2; if (left != null) { left[leftOff + 2] = x1; left[leftOff + 3] = y1; left[leftOff + 4] = xc; left[leftOff + 5] = yc; } if (right != null) { right[rightOff] = xc; right[rightOff + 1] = yc; right[rightOff + 2] = x2; right[rightOff + 3] = y2; } }
|
{ right[rightOff + 4] = x2; right[rightOff + 5] = y2; } x1 = (x1 + xc) / 2; x2 = (xc + x2) / 2; xc = (x1 + x2) / 2; y1 = (y1 + yc) / 2; y2 = (y2 + yc) / 2; yc = (y1 + y2) / 2; if (left != null) { left[leftOff + 2] = x1; left[leftOff + 3] = y1; left[leftOff + 4] = xc; left[leftOff + 5] = yc; } if (right != null) { right[rightOff] = xc; right[rightOff + 1] = yc; right[rightOff + 2] = x2; right[rightOff + 3] = y2; }
|
right.setCurve(d, 4);
|
public static void subdivide(double[] src, int srcOff, double[] left, int leftOff, double[] right, int rightOff) { double x1; double y1; double xc; double yc; double x2; double y2; x1 = src[srcOff]; y1 = src[srcOff + 1]; xc = src[srcOff + 2]; yc = src[srcOff + 3]; x2 = src[srcOff + 4]; y2 = src[srcOff + 5]; if (left != null) { left[leftOff] = x1; left[leftOff + 1] = y1; } if (right != null) { right[rightOff + 4] = x2; right[rightOff + 5] = y2; } x1 = (x1 + xc) / 2; x2 = (xc + x2) / 2; xc = (x1 + x2) / 2; y1 = (y1 + yc) / 2; y2 = (y2 + yc) / 2; yc = (y1 + y2) / 2; if (left != null) { left[leftOff + 2] = x1; left[leftOff + 3] = y1; left[leftOff + 4] = xc; left[leftOff + 5] = yc; } if (right != null) { right[rightOff] = xc; right[rightOff + 1] = yc; right[rightOff + 2] = x2; right[rightOff + 3] = y2; } }
|
public float[] getSamples(int x, int y, int w, int h, int b, float[] fArray)
|
public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray)
|
public float[] getSamples(int x, int y, int w, int h, int b, float[] fArray) { return sampleModel.getSamples(x-sampleModelTranslateX, y-sampleModelTranslateY, w, h, b, fArray, dataBuffer); }
|
w, h, b, fArray, dataBuffer);
|
w, h, b, iArray, dataBuffer);
|
public float[] getSamples(int x, int y, int w, int h, int b, float[] fArray) { return sampleModel.getSamples(x-sampleModelTranslateX, y-sampleModelTranslateY, w, h, b, fArray, dataBuffer); }
|
public void setSample(int x, int y, int b, float s)
|
public void setSample(int x, int y, int b, int s)
|
public void setSample(int x, int y, int b, float s) { sampleModel.setSample(x-sampleModelTranslateX, y-sampleModelTranslateY, b, s, dataBuffer); }
|
if (input.charAt(mymatch.index+i-b) != input.charAt(i)) {
|
char c1 = input.charAt(mymatch.index+i-b); char c2 = input.charAt(i); if (c1 != c2) { if (insens) { if (c1 != Character.toLowerCase(c2) && c1 != Character.toUpperCase(c2)) {
|
boolean match(CharIndexed input, REMatch mymatch) { int b,e; b = mymatch.start[num]; e = mymatch.end[num]; if ((b==-1)||(e==-1)) return false; // this shouldn't happen, but... for (int i=b; i<e; i++) { if (input.charAt(mymatch.index+i-b) != input.charAt(i)) { return false; } } mymatch.index += e-b; return next(input, mymatch); }
|
return next(input, mymatch);
|
boolean result = next(input, mymatch); if (result) mymatch.empty = (mymatch.index == origin); return result;
|
boolean match(CharIndexed input, REMatch mymatch) { int b,e; b = mymatch.start[num]; e = mymatch.end[num]; if ((b==-1)||(e==-1)) return false; // this shouldn't happen, but... for (int i=b; i<e; i++) { if (input.charAt(mymatch.index+i-b) != input.charAt(i)) { return false; } } mymatch.index += e-b; return next(input, mymatch); }
|
public Object getNextValue();
|
Object getNextValue();
|
public Object getNextValue();
|
public Object getPreviousValue();
|
Object getPreviousValue();
|
public Object getPreviousValue();
|
public Object getValue();
|
Object getValue();
|
public Object getValue();
|
producer.setFeature(handler.FEATURE_URI + "namespace-prefixes",
|
producer.setFeature(EventFilter.FEATURE_URI + "namespace-prefixes",
|
public void transform (Source in, Result out) throws TransformerException { try { XMLReader producer; InputSource input; // Input from DOM? if (in instanceof DOMSource) { DOMSource source = (DOMSource) in; if (source.getNode () == null) throw new IllegalArgumentException ("no DOM node"); producer = new DomParser (source.getNode ()); input = null; // Input from SAX? } else if (in instanceof SAXSource) { SAXSource source = (SAXSource) in; producer = source.getXMLReader (); if (producer == null) producer = XMLReaderFactory.createXMLReader (); input = source.getInputSource (); if (input == null) { if (source.getSystemId () != null) input = new InputSource (source.getSystemId ()); else throw new IllegalArgumentException ( "missing SAX input"); } // Input from a stream or something? } else { producer = XMLReaderFactory.createXMLReader (); input = SAXSource.sourceToInputSource (in); if (input == null) throw new IllegalArgumentException ("missing input"); } // preserve original namespace prefixes try { producer.setFeature(handler.FEATURE_URI + "namespace-prefixes", true); } catch (Exception e) { /* ignore */ // FIXME if we couldn't, "NsFix" stage before the output .. } // arrange the output handler.setResult (out); handler.bind (producer, handler); // then parse ... single element pipeline producer.parse (input); } catch (IOException e) { throw new TransformerException ("transform failed", e); } catch (SAXException e) { if (ex == null && ex.getCause () == e) throw ex; else throw new TransformerException ("transform failed", e); } finally { ex = null; } }
|
handler.bind (producer, handler);
|
EventFilter.bind (producer, handler);
|
public void transform (Source in, Result out) throws TransformerException { try { XMLReader producer; InputSource input; // Input from DOM? if (in instanceof DOMSource) { DOMSource source = (DOMSource) in; if (source.getNode () == null) throw new IllegalArgumentException ("no DOM node"); producer = new DomParser (source.getNode ()); input = null; // Input from SAX? } else if (in instanceof SAXSource) { SAXSource source = (SAXSource) in; producer = source.getXMLReader (); if (producer == null) producer = XMLReaderFactory.createXMLReader (); input = source.getInputSource (); if (input == null) { if (source.getSystemId () != null) input = new InputSource (source.getSystemId ()); else throw new IllegalArgumentException ( "missing SAX input"); } // Input from a stream or something? } else { producer = XMLReaderFactory.createXMLReader (); input = SAXSource.sourceToInputSource (in); if (input == null) throw new IllegalArgumentException ("missing input"); } // preserve original namespace prefixes try { producer.setFeature(handler.FEATURE_URI + "namespace-prefixes", true); } catch (Exception e) { /* ignore */ // FIXME if we couldn't, "NsFix" stage before the output .. } // arrange the output handler.setResult (out); handler.bind (producer, handler); // then parse ... single element pipeline producer.parse (input); } catch (IOException e) { throw new TransformerException ("transform failed", e); } catch (SAXException e) { if (ex == null && ex.getCause () == e) throw ex; else throw new TransformerException ("transform failed", e); } finally { ex = null; } }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.