rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
if (peer != null) return peer.getGraphics().getFont(); | public Font getFont() { Font f = font; if (f != null) return f; Component p = parent; if (p != null) return p.getFont(); return null; } |
|
if (parent != null && parent.valid) | if (parent != null && parent.isValid()) | public void invalidate() { valid = false; prefSize = null; minSize = null; if (parent != null && parent.valid) parent.invalidate(); } |
if(!isShowing()) { Component p = parent; if (p != null) p.repaint(0, getX(), getY(), width, height); } else | if (isShowing()) | public void repaint() { if(!isShowing()) { Component p = parent; if (p != null) p.repaint(0, getX(), getY(), width, height); } else repaint(0, 0, 0, width, height); } |
Rectangle parentBounds = parent.getBounds(); | public void reshape(int x, int y, int width, int height) { int oldx = this.x; int oldy = this.y; int oldwidth = this.width; int oldheight = this.height; if (this.x == x && this.y == y && this.width == width && this.height == height) return; invalidate (); this.x = x; this.y = y; this.width = width; this.height = height; if (peer != null) peer.setBounds (x, y, width, height); // Erase old bounds and repaint new bounds for lightweights. if (isLightweight() && isShowing ()) { if (parent != null) { Rectangle parentBounds = parent.getBounds(); Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth, oldheight); Rectangle newBounds = new Rectangle(x, y, width, height); Rectangle destroyed = oldBounds.union(newBounds); if (!destroyed.isEmpty()) parent.repaint(0, destroyed.x, destroyed.y, destroyed.width, destroyed.height); } } // Only post event if this component is visible and has changed size. if (isShowing () && (oldx != x || oldy != y)) { ComponentEvent ce = new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED); getToolkit().getSystemEventQueue().postEvent(ce); } if (isShowing () && (oldwidth != width || oldheight != height)) { ComponentEvent ce = new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED); getToolkit().getSystemEventQueue().postEvent(ce); } } |
|
if (c == null && parent != null) c = parent.getBackground(); if (peer != null && c != null) peer.setBackground(c); | public void setBackground(Color c) { // return if the background is already set to that color. if ((c != null) && c.equals(background)) return; // If c is null, inherit from closest ancestor whose bg is set. if (c == null && parent != null) c = parent.getBackground(); if (peer != null && c != null) peer.setBackground(c); Color previous = background; background = c; firePropertyChange("background", previous, c); } |
|
if (peer != null && c != null) peer.setBackground(c); | public void setBackground(Color c) { // return if the background is already set to that color. if ((c != null) && c.equals(background)) return; // If c is null, inherit from closest ancestor whose bg is set. if (c == null && parent != null) c = parent.getBackground(); if (peer != null && c != null) peer.setBackground(c); Color previous = background; background = c; firePropertyChange("background", previous, c); } |
|
ValueListInterface valueListObj = (ValueListInterface) iter.next(); | ValueList valueListObj = (ValueList) iter.next(); | protected String basicXMLWriter ( Writer outputWriter, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) throws java.io.IOException { // while writing out, attribHash should not be changed synchronized (attribHash) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write(indent); // indent node if desired outputWriter.write("<" + nodeNameString); // print opening statement } // gather info about Attributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { int size = attribs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) attribs.get(i); outputWriter.write( " " + item.get("name") + "=\""); // this slows things down, should we use? writeOutAttribute(outputWriter, (String) item.get("value")); // outputWriter.write( (String) item.get("value")); outputWriter.write( "\"" ); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); List childXMLElements = getElementNodeList(); String pcdata = (String) xmlInfo.get("PCDATA"); if ( childObjs.size() > 0 || childXMLElements.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { outputWriter.write( ">"); if ((Specification.getInstance().isPrettyXDFOutput()) && (pcdata == null)) outputWriter.write( Constants.NEW_LINE); } // by definition these are printed first int size = childXMLElements.size(); String childindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); for (int i = 0; i < size; i++) { ((ElementNode) childXMLElements.get(i)).toXMLWriter(outputWriter, childindent); } // deal with object/list XML attributes, if any in our list size = childObjs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { if (hasValueListCompactDescription && valueListXMLItemName.equals(item.get("name"))) { Iterator iter = valueListObjects.iterator(); while(iter.hasNext()) { ValueListInterface valueListObj = (ValueListInterface) iter.next(); // first determine if groups should open or close // using the first value in the values list. List values = valueListObj.getValues(); Value valueObj = (Value) values.get(0); // *sigh* Yes, we have to check that all values belong to // the same groups, or problems will arise in the output. Do that here. boolean canUseCompactValueDescription = true; Set firstValueGroups = valueObj.openGroupNodeHash; Iterator valueIter = values.iterator(); valueIter.next(); // no need to do first group while (valueIter.hasNext()) { Value thisValue = (Value) valueIter.next(); if (thisValue != null) { Set thisValuesGroups = thisValue.openGroupNodeHash; if (!firstValueGroups.equals(thisValuesGroups)) { // Note this comparison also does size too Log.infoln("Cant use short description for values because some values have differing groups! Using long description instead."); canUseCompactValueDescription = false; break; } } } if (canUseCompactValueDescription) { // use compact description indent = dealWithClosingGroupNodes((BaseObject) valueObj, outputWriter, indent); indent = dealWithOpeningGroupNodes((BaseObject) valueObj, outputWriter, indent); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); // now print the valuelist itself valueListObj.toXMLWriter(outputWriter, newindent); } else { // use regular (long) method List objectList = (List) item.get("value"); indent = objectListToXMLWriter(outputWriter, objectList, indent); } } } else { // use regular method List objectList = (List) item.get("value"); indent = objectListToXMLWriter(outputWriter, objectList, indent); } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { indent = dealWithClosingGroupNodes(containedObj, outputWriter, indent); indent = dealWithOpeningGroupNodes(containedObj, outputWriter, indent); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); containedObj.toXMLWriter(outputWriter, newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { outputWriter.write(entifyString(pcdata)); }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write( indent + Specification.getInstance().getPrettyXDFOutputIndentation()); outputWriter.write("<" + noChildObjectNodeName + "/>"); if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write( Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputWriter, indent); if (Specification.getInstance().isPrettyXDFOutput() && pcdata == null) outputWriter.write( indent); if (!dontCloseNode) outputWriter.write( "</"+nodeNameString+">"); } } else { if (nodeNameString != null) { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) outputWriter.write( ">"); } else { // no sub-objects, just close this node outputWriter.write( "/>"); } } } // if (Specification.getInstance().isPrettyXDFOutput() && nodeNameString != null ) // outputWriter.write( Constants.NEW_LINE); return nodeNameString; } //end synchronize } |
protected void setValueListObj (ValueListInterface valueListObj) | protected void setValueListObj (ValueList valueListObj) | protected void setValueListObj (ValueListInterface valueListObj) { resetValueListObjects(); addValueListObj(valueListObj); } |
repaint(); | calculateVisibility(); | public MyInternalFrame() { super("#" + (++openFrameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable internalId = openFrameCount; //...Create the GUI and put it in the window... //...Then set the window size or call pack... setSize(600,500); //Set the window's location. setLocation(xOffset*openFrameCount, yOffset*openFrameCount); addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) {// displayMessage("Internal frame closing", e); disconnectMe(); } public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); disconnectMe(); } public void internalFrameOpened(InternalFrameEvent e) {// displayMessage("Internal frame opened", e); } public void internalFrameIconified(InternalFrameEvent e) {// displayMessage("Internal frame iconified", e); } public void internalFrameDeiconified(InternalFrameEvent e) {// displayMessage("Internal frame deiconified", e); repaint(); } public void internalFrameActivated(InternalFrameEvent e) {// displayMessage("Internal frame activated", e); activated = true; repaint(); } public void internalFrameDeactivated(InternalFrameEvent e) { activated = false;// displayMessage("Internal frame deactivated", e); } }); } |
calculateVisibility(); | public MyInternalFrame() { super("#" + (++openFrameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable internalId = openFrameCount; //...Create the GUI and put it in the window... //...Then set the window size or call pack... setSize(600,500); //Set the window's location. setLocation(xOffset*openFrameCount, yOffset*openFrameCount); addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) {// displayMessage("Internal frame closing", e); disconnectMe(); } public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); disconnectMe(); } public void internalFrameOpened(InternalFrameEvent e) {// displayMessage("Internal frame opened", e); } public void internalFrameIconified(InternalFrameEvent e) {// displayMessage("Internal frame iconified", e); } public void internalFrameDeiconified(InternalFrameEvent e) {// displayMessage("Internal frame deiconified", e); repaint(); } public void internalFrameActivated(InternalFrameEvent e) {// displayMessage("Internal frame activated", e); activated = true; repaint(); } public void internalFrameDeactivated(InternalFrameEvent e) { activated = false;// displayMessage("Internal frame deactivated", e); } }); } |
|
repaint(); | calculateVisibility(); | public void internalFrameActivated(InternalFrameEvent e) {// displayMessage("Internal frame activated", e); activated = true; repaint(); } |
calculateVisibility(); | public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); disconnectMe(); } |
|
calculateVisibility(); | public void internalFrameClosing(InternalFrameEvent e) {// displayMessage("Internal frame closing", e); disconnectMe(); } |
|
calculateVisibility(); | public void internalFrameDeactivated(InternalFrameEvent e) { activated = false;// displayMessage("Internal frame deactivated", e); } |
|
repaint(); | calculateVisibility(); | public void internalFrameDeiconified(InternalFrameEvent e) {// displayMessage("Internal frame deiconified", e); repaint(); } |
calculateVisibility(); | public void internalFrameIconified(InternalFrameEvent e) {// displayMessage("Internal frame iconified", e); } |
|
calculateVisibility(); | public void internalFrameOpened(InternalFrameEvent e) {// displayMessage("Internal frame opened", e); } |
|
if (mif.isIcon()) mif.setIcon(false); | private void nextSession() { MyInternalFrame mif = getNextInternalFrame(); if (mif != null) { try { mif.setSelected(true); if (mif.isIcon()) mif.setIcon(false); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } }// System.out.println(" current index " + index + " count " + desktop.getComponentCount()); } |
|
System.out.println(" index of session " + index + " num frames " + desktop.getAllFrames().length); | public void onSessionChanged(SessionChangeEvent changeEvent) { Session ses = (Session)changeEvent.getSource(); switch (changeEvent.getState()) { case STATE_CONNECTED: final String d = ses.getAllocDeviceName(); if (d != null) { System.out.println(changeEvent.getState() + " " + d); final int index = getIndexOfSession(ses); System.out.println(" index of session " + index + " num frames " + desktop.getAllFrames().length); if (index == -1) return; Runnable tc = new Runnable () { public void run() { JInternalFrame[] frames = desktop.getAllFrames(); frames[index].setTitle(frames[index].getTitle() + " " + d); } }; SwingUtilities.invokeLater(tc); } break; } } |
|
frames[index].setTitle(frames[index].getTitle() + " " + d); | int id = ((MyInternalFrame)frames[index]).getInternalId(); frames[index].setTitle("#" + id + " " + d); | public void onSessionChanged(SessionChangeEvent changeEvent) { Session ses = (Session)changeEvent.getSource(); switch (changeEvent.getState()) { case STATE_CONNECTED: final String d = ses.getAllocDeviceName(); if (d != null) { System.out.println(changeEvent.getState() + " " + d); final int index = getIndexOfSession(ses); System.out.println(" index of session " + index + " num frames " + desktop.getAllFrames().length); if (index == -1) return; Runnable tc = new Runnable () { public void run() { JInternalFrame[] frames = desktop.getAllFrames(); frames[index].setTitle(frames[index].getTitle() + " " + d); } }; SwingUtilities.invokeLater(tc); } break; } } |
frames[index].setTitle(frames[index].getTitle() + " " + d); | int id = ((MyInternalFrame)frames[index]).getInternalId(); frames[index].setTitle("#" + id + " " + d); | public void run() { JInternalFrame[] frames = desktop.getAllFrames(); frames[index].setTitle(frames[index].getTitle() + " " + d); } |
((MyInternalFrame)myFrameList.get(index)).setSelected(true); if (((MyInternalFrame)myFrameList.get(index)).isIcon()) ((MyInternalFrame)myFrameList.get(index)).setIcon(false); | MyInternalFrame mif = (MyInternalFrame)myFrameList.get(index); if (mif.isIcon()) { mif.setIcon(false); } mif.setSelected(true); | private void prevSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = desktop.getSelectedFrame(); if (miv == null) return; int index = desktop.getIndexOf(miv); if (index == -1) return; MyInternalFrame mix = (MyInternalFrame)frames[index]; int seq = mix.getInternalId(); index = 0; for (int x = 0; x < myFrameList.size(); x++) { MyInternalFrame mif = (MyInternalFrame)myFrameList.get(x);// System.out.println(" current index " + x + " count " + frames.length + " has focus " +// mif.isActive() + " title " + mif.getTitle() + " seq " + seq +// " id " + mif.getInternalId()); if (mix.equals(mif)) { index = x - 1; break; } } if (index < 0) { index = myFrameList.size() - 1; } try { ((MyInternalFrame)myFrameList.get(index)).setSelected(true); if (((MyInternalFrame)myFrameList.get(index)).isIcon()) ((MyInternalFrame)myFrameList.get(index)).setIcon(false); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); }// System.out.println(" current index " + index + " count " + desktop.getComponentCount()); } |
if (!workStroke.equals(ke)) { workStroke.setAttributes(ke); lastKeyMnemonic = (String)mappedKeys.get(workStroke); } return lastKeyMnemonic; | return getKeyStrokeText(ke,false); | public final static String getKeyStrokeText(KeyEvent ke) { if (!workStroke.equals(ke)) { workStroke.setAttributes(ke); lastKeyMnemonic = (String)mappedKeys.get(workStroke); } return lastKeyMnemonic; } |
settings.setProperty("emulator.settingsDirectory", System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator); | private void checkLegacy() { // we check if the sessions file already exists in the directory // if it does exist we are working with an old install so we // need to set the settings directory to the users directory // SESSIONS is declared as a string, so we just can use the keyword here. if(ses.exists()) { int cfc; cfc = JOptionPane.showConfirmDialog(null, "Dear User,\n\n" + "Seems you are using an old version of tn5250j.\n" + "In meanwhile the application became multi-user capable,\n" + "which means ALL the config- and settings-files are\n" + "placed in your home-dir to avoid further problems in\n" + "the near future.\n\n" + "You have the choice to choose if you want the files\n" + "to be copied or not, please make your choice !\n\n" + "Shall we copy the files to the new location ?", "Old install detected", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); if (cfc == 0) { settings.setProperty("emulator.settingsDirectory", System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator); // Here we do a checkdir so we know the destination-dir exists checkDirs(); copyConfigs(SESSIONS); copyConfigs(MACROS); copyConfigs(KEYMAP); } else { JOptionPane.showMessageDialog(null, "Dear User,\n\n" + "You choosed not to copy the file.\n" + "This means the program will end here.\n\n" + "To use this NON-STANDARD behaviour start tn5250j\n" + "with -Demulator.settingsDirectory=<settings-dir> \n" + "as a parameter to avoid this question all the time.", "Using NON-STANDARD behaviour", JOptionPane.WARNING_MESSAGE); System.exit(0); } } else { settings.setProperty("emulator.settingsDirectory", System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator); System.out.println("User Home = " + System.getProperty("user.home")); } } |
|
else { settings.setProperty("emulator.settingsDirectory", System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator); System.out.println("User Home = " + System.getProperty("user.home")); } | private void checkLegacy() { // we check if the sessions file already exists in the directory // if it does exist we are working with an old install so we // need to set the settings directory to the users directory // SESSIONS is declared as a string, so we just can use the keyword here. if(ses.exists()) { int cfc; cfc = JOptionPane.showConfirmDialog(null, "Dear User,\n\n" + "Seems you are using an old version of tn5250j.\n" + "In meanwhile the application became multi-user capable,\n" + "which means ALL the config- and settings-files are\n" + "placed in your home-dir to avoid further problems in\n" + "the near future.\n\n" + "You have the choice to choose if you want the files\n" + "to be copied or not, please make your choice !\n\n" + "Shall we copy the files to the new location ?", "Old install detected", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); if (cfc == 0) { settings.setProperty("emulator.settingsDirectory", System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator); // Here we do a checkdir so we know the destination-dir exists checkDirs(); copyConfigs(SESSIONS); copyConfigs(MACROS); copyConfigs(KEYMAP); } else { JOptionPane.showMessageDialog(null, "Dear User,\n\n" + "You choosed not to copy the file.\n" + "This means the program will end here.\n\n" + "To use this NON-STANDARD behaviour start tn5250j\n" + "with -Demulator.settingsDirectory=<settings-dir> \n" + "as a parameter to avoid this question all the time.", "Using NON-STANDARD behaviour", JOptionPane.WARNING_MESSAGE); System.exit(0); } } else { settings.setProperty("emulator.settingsDirectory", System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator); System.out.println("User Home = " + System.getProperty("user.home")); } } |
|
again = new FileInputStream(System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator + settingsFile); | again = new FileInputStream(settingsDirectory() + settingsFile); | private void loadSettings() { FileInputStream in = null; FileInputStream again = null; settings = new Properties(); // here we will check for a system property is provided first. if (System.getProperties().containsKey("emulator.settingsDirectory")) { settings.setProperty("emulator.settingsDirectory", System.getProperty("emulator.settingsDirectory") + File.separator); checkDirs(); } else { try { in = new FileInputStream(settingsFile); settings.load(in); } catch (FileNotFoundException fnfe) { try { again = new FileInputStream(System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator + settingsFile); settings.load(again); } catch (FileNotFoundException fnfea) { System.out.println(" Information Message: " + fnfea.getMessage() + ". The file " + settingsFile + " will be created for first time use."); checkLegacy(); saveSettings(); } catch (IOException ioea) { System.out.println("IO Exception accessing File " + settingsFile + " for the following reason : " + ioea.getMessage()); } catch (SecurityException sea) { System.out.println("Security Exception for file " + settingsFile + " This file can not be " + "accessed because : " + sea.getMessage()); } } catch (IOException ioe) { System.out.println("IO Exception accessing File " + settingsFile + " for the following reason : " + ioe.getMessage()); } catch (SecurityException se) { System.out.println("Security Exception for file " + settingsFile + " This file can not be " + "accessed because : " + se.getMessage()); } } } |
FileOutputStream out = new FileOutputStream(settingsFile); | FileOutputStream out = new FileOutputStream(settingsDirectory() + settingsFile); | public void saveSettings() { try { FileOutputStream out = new FileOutputStream(settingsFile); settings.store(out,"----------------- tn5250j Global Settings --------------"); } catch (FileNotFoundException fnfe) {} catch (IOException ioe) {} } |
super(in); | this.in = in; | public ChunkedInputStream(InputStream in, Headers headers) { super(in); this.headers = headers; size = -1; count = 0; meta = true; } |
throw new IllegalArgumentException(); | throw new IllegalArgumentException(titleJustification + " is not a valid title justification."); | public void setTitleJustification(int titleJustification) { if ((titleJustification < DEFAULT_JUSTIFICATION) || (titleJustification > TRAILING)) throw new IllegalArgumentException(); // Swing borders are not JavaBeans, thus no need to fire an event. this.titleJustification = titleJustification; } |
throw new IllegalArgumentException(); | throw new IllegalArgumentException(titlePosition + " is not a valid title position."); | public void setTitlePosition(int titlePosition) { if ((titlePosition < DEFAULT_POSITION) || (titlePosition > BELOW_BOTTOM)) throw new IllegalArgumentException(); // Swing borders are not JavaBeans, thus no need to fire an event. this.titlePosition = titlePosition; } |
if ((event.getPropertyName()).equals("rootVisible")) { validCachedPreferredSize = false; updateCurrentVisiblePath(); tree.revalidate(); tree.repaint(); } | public void propertyChange(PropertyChangeEvent event) { // TODO: What should be done here, if anything? } |
|
if (i-1 > 0) | if (i-1 >= 0) | Object getPreviousVisibleNode(Object node) { if (currentVisiblePath != null) { Object[] nodes = currentVisiblePath.getPath(); int i = 0; while (i < nodes.length && !node.equals(nodes[i])) i++; // return the next node if (i-1 > 0) return nodes[i-1]; } return null; } |
updateCurrentVisiblePath(); | public int getRowCount(JTree tree) { if (currentVisiblePath != null) return currentVisiblePath.getPathCount(); return 0; } |
|
if (treeModel != null) | if (currentVisiblePath != null && treeModel != null) | public void paint(Graphics g, JComponent c) { JTree tree = (JTree) c; if (currentVisiblePath == null) updateCurrentVisiblePath(); if (treeModel != null) { Object root = treeModel.getRoot(); paintRecursive(g, 0, 0, 0, tree, treeModel, root); if (hasControlIcons()) paintControlIcons(g, 0, 0, 0, tree, treeModel, root); } } |
if (tree.isVisible(new TreePath(getPathToRoot(child, 0)))) | int paintControlIcons(Graphics g, int indentation, int descent, int depth, JTree tree, TreeModel mod, Object node) { 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 (!node.equals(mod.getRoot()) && (tree.isRootVisible() || getLevel(node) != 1)) { int width = icon.getIconWidth(); int height = icon.getIconHeight() + 2; int posX = indentation - rightChildIndent; int posY = descent; if (width > rightChildIndent) posX -= gap; else posX += width/2; if (height < rowHeight) posY += height/2; icon.paintIcon(tree, g, posX, posY); } if (depth > 0 || tree.isRootVisible()) descent += rowHeight; if (tree.isExpanded(path)) { int max = 0; if (!mod.isLeaf(node)) max = mod.getChildCount(node); for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (depth == 0 && !tree.isRootVisible()) indent = 1; descent = paintControlIcons(g, indent, descent, depth + 1, tree, mod, mod.getChild(node, i)); } } } return descent; } |
|
tree, mod, mod.getChild(node, i)); | tree, mod, child); | int paintControlIcons(Graphics g, int indentation, int descent, int depth, JTree tree, TreeModel mod, Object node) { 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 (!node.equals(mod.getRoot()) && (tree.isRootVisible() || getLevel(node) != 1)) { int width = icon.getIconWidth(); int height = icon.getIconHeight() + 2; int posX = indentation - rightChildIndent; int posY = descent; if (width > rightChildIndent) posX -= gap; else posX += width/2; if (height < rowHeight) posY += height/2; icon.paintIcon(tree, g, posX, posY); } if (depth > 0 || tree.isRootVisible()) descent += rowHeight; if (tree.isExpanded(path)) { int max = 0; if (!mod.isLeaf(node)) max = mod.getChildCount(node); for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (depth == 0 && !tree.isRootVisible()) indent = 1; descent = paintControlIcons(g, indent, descent, depth + 1, tree, mod, mod.getChild(node, i)); } } } return descent; } |
(!isRootVisible && !curr.equals(root))) | (!isRootVisible && !curr.equals(root)) && childVis) | int paintRecursive(Graphics g, int indentation, int descent, 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; TreePath path = new TreePath(getPathToRoot(curr, 0)); int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; int row = getRowForPath(tree, path); boolean isRootVisible = tree.isRootVisible(); boolean isExpanded = tree.isExpanded(path); boolean isLeaf = mod.isLeaf(curr); Rectangle bounds = getPathBounds(tree, path); Object root = mod.getRoot(); if (isLeaf) { paintRow(g, clip, null, bounds, path, row, true, false, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintRow(g, clip, null, bounds, path, row, isExpanded, false, false); descent += getRowHeight(); y0 += halfHeight; } if (isExpanded) { int max = mod.getChildCount(curr); for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if (isRootVisible || (!isRootVisible && !curr.equals(root))) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (isExpanded) if (y0 != heightOfLine && !isLeaf && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; } |
tree, mod, mod.getChild(curr, i)); | tree, mod, child); | int paintRecursive(Graphics g, int indentation, int descent, 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; TreePath path = new TreePath(getPathToRoot(curr, 0)); int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; int row = getRowForPath(tree, path); boolean isRootVisible = tree.isRootVisible(); boolean isExpanded = tree.isExpanded(path); boolean isLeaf = mod.isLeaf(curr); Rectangle bounds = getPathBounds(tree, path); Object root = mod.getRoot(); if (isLeaf) { paintRow(g, clip, null, bounds, path, row, true, false, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintRow(g, clip, null, bounds, path, row, isExpanded, false, false); descent += getRowHeight(); y0 += halfHeight; } if (isExpanded) { int max = mod.getChildCount(curr); for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if (isRootVisible || (!isRootVisible && !curr.equals(root))) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (isExpanded) if (y0 != heightOfLine && !isLeaf && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; } |
if (y0 != heightOfLine && !isLeaf && mod.getChildCount(curr) > 0) | if (y0 != heightOfLine && (mod.getChildCount(curr) > 0 && tree.isVisible(new TreePath(getPathToRoot(mod.getChild (curr, 0), 0))))) | int paintRecursive(Graphics g, int indentation, int descent, 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; TreePath path = new TreePath(getPathToRoot(curr, 0)); int halfHeight = getRowHeight() / 2; int halfWidth = rightChildIndent / 2; int y0 = descent + halfHeight; int heightOfLine = descent + halfHeight; int row = getRowForPath(tree, path); boolean isRootVisible = tree.isRootVisible(); boolean isExpanded = tree.isExpanded(path); boolean isLeaf = mod.isLeaf(curr); Rectangle bounds = getPathBounds(tree, path); Object root = mod.getRoot(); if (isLeaf) { paintRow(g, clip, null, bounds, path, row, true, false, true); descent += getRowHeight(); } else { if (depth > 0 || isRootVisible) { paintRow(g, clip, null, bounds, path, row, isExpanded, false, false); descent += getRowHeight(); y0 += halfHeight; } if (isExpanded) { int max = mod.getChildCount(curr); for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if (isRootVisible || (!isRootVisible && !curr.equals(root))) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; paintHorizontalLine(g, (JComponent) tree, heightOfLine, indentation + halfWidth, indentation + rightChildIndent); } descent = paintRecursive(g, indent, descent, depth + 1, tree, mod, mod.getChild(curr, i)); } } } if (isExpanded) if (y0 != heightOfLine && !isLeaf && mod.getChildCount(curr) > 0) { g.setColor(getHashColor()); paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, heightOfLine); } return descent; } |
selected, isExpanded, isLeaf, row, false); | selected, isExpanded, isLeaf, row, true); | protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { boolean selected = tree.isPathSelected(path); boolean hasIcons = false; Object node = path.getLastPathComponent(); if (tree.isVisible(path)) { if (!validCachedPreferredSize) updateCachedPreferredSize(); bounds.x += gap; bounds.width = preferredSize.width + bounds.x; 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); rendererPane.paintComponent(g, c, c.getParent(), bounds); } } } |
if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible() | if ((bounds.width == 0 && bounds.height == 0) || (!rootVisible | void updateCurrentVisiblePath() { if (treeModel == null) return; Object next = treeModel.getRoot(); Rectangle bounds = getCellBounds(0, 0, next); // If root is not a valid size to be visible, or is // not visible and the tree is expanded, then the next node acts // as the root if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible() && tree.isExpanded(new TreePath(next)))) next = getNextNode(next); TreePath current = null; while (next != null) { if (current == null) current = new TreePath(next); else current = current.pathByAddingChild(next); do { TreePath path = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(path) && tree.isExpanded(path)) next = getNextNode(next); else next = getNextSibling(next); } while (next != null && !tree.isVisible(new TreePath(getPathToRoot(next, 0)))); } currentVisiblePath = current; tree.setVisibleRowCount(getRowCount(tree)); if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 && currentVisiblePath != null) tree.addSelectionRow(0); } |
if (tree.isVisible(path) && tree.isExpanded(path)) | if ((tree.isVisible(path) && tree.isExpanded(path)) || treeModel.isLeaf(next)) | void updateCurrentVisiblePath() { if (treeModel == null) return; Object next = treeModel.getRoot(); Rectangle bounds = getCellBounds(0, 0, next); // If root is not a valid size to be visible, or is // not visible and the tree is expanded, then the next node acts // as the root if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible() && tree.isExpanded(new TreePath(next)))) next = getNextNode(next); TreePath current = null; while (next != null) { if (current == null) current = new TreePath(next); else current = current.pathByAddingChild(next); do { TreePath path = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(path) && tree.isExpanded(path)) next = getNextNode(next); else next = getNextSibling(next); } while (next != null && !tree.isVisible(new TreePath(getPathToRoot(next, 0)))); } currentVisiblePath = current; tree.setVisibleRowCount(getRowCount(tree)); if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 && currentVisiblePath != null) tree.addSelectionRow(0); } |
tree.setVisibleRowCount(getRowCount(tree)); | if (currentVisiblePath != null) tree.setVisibleRowCount(currentVisiblePath.getPathCount()); else tree.setVisibleRowCount(0); | void updateCurrentVisiblePath() { if (treeModel == null) return; Object next = treeModel.getRoot(); Rectangle bounds = getCellBounds(0, 0, next); // If root is not a valid size to be visible, or is // not visible and the tree is expanded, then the next node acts // as the root if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible() && tree.isExpanded(new TreePath(next)))) next = getNextNode(next); TreePath current = null; while (next != null) { if (current == null) current = new TreePath(next); else current = current.pathByAddingChild(next); do { TreePath path = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(path) && tree.isExpanded(path)) next = getNextNode(next); else next = getNextSibling(next); } while (next != null && !tree.isVisible(new TreePath(getPathToRoot(next, 0)))); } currentVisiblePath = current; tree.setVisibleRowCount(getRowCount(tree)); if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 && currentVisiblePath != null) tree.addSelectionRow(0); } |
tree.addSelectionRow(0); | selectPath(tree, new TreePath(currentVisiblePath.getPathComponent(0))); | void updateCurrentVisiblePath() { if (treeModel == null) return; Object next = treeModel.getRoot(); Rectangle bounds = getCellBounds(0, 0, next); // If root is not a valid size to be visible, or is // not visible and the tree is expanded, then the next node acts // as the root if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible() && tree.isExpanded(new TreePath(next)))) next = getNextNode(next); TreePath current = null; while (next != null) { if (current == null) current = new TreePath(next); else current = current.pathByAddingChild(next); do { TreePath path = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(path) && tree.isExpanded(path)) next = getNextNode(next); else next = getNextSibling(next); } while (next != null && !tree.isVisible(new TreePath(getPathToRoot(next, 0)))); } currentVisiblePath = current; tree.setVisibleRowCount(getRowCount(tree)); if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 && currentVisiblePath != null) tree.addSelectionRow(0); } |
throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE); | throw new BAD_OPERATION(Minor.Method, CompletionStatus.COMPLETED_MAYBE); | OutputStream super_invoke(String method, InputStream in, ResponseHandler rh) { OutputStream out = null; Integer call_method = (Integer) _NamingContextImplBase.methods.get(method); if (call_method == null) throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE); switch (call_method.intValue()) { case 0: // bind { try { NameComponent[] a_name = NameHelper.read(in); org.omg.CORBA.Object an_object = ObjectHelper.read(in); bind(a_name, an_object); out = rh.createReply(); } catch (NotFound ex) { out = rh.createExceptionReply(); NotFoundHelper.write(out, ex); } catch (CannotProceed ex) { out = rh.createExceptionReply(); CannotProceedHelper.write(out, ex); } catch (InvalidName ex) { out = rh.createExceptionReply(); InvalidNameHelper.write(out, ex); } catch (AlreadyBound ex) { out = rh.createExceptionReply(); AlreadyBoundHelper.write(out, ex); } break; } case 1: // rebind { try { NameComponent[] a_name = NameHelper.read(in); org.omg.CORBA.Object an_object = ObjectHelper.read(in); rebind(a_name, an_object); out = rh.createReply(); } catch (NotFound ex) { out = rh.createExceptionReply(); NotFoundHelper.write(out, ex); } catch (CannotProceed ex) { out = rh.createExceptionReply(); CannotProceedHelper.write(out, ex); } catch (InvalidName ex) { out = rh.createExceptionReply(); InvalidNameHelper.write(out, ex); } break; } case 2: // bind_context { try { NameComponent[] a_name = NameHelper.read(in); NamingContext a_context = NamingContextHelper.read(in); bind_context(a_name, a_context); out = rh.createReply(); } catch (NotFound ex) { out = rh.createExceptionReply(); NotFoundHelper.write(out, ex); } catch (CannotProceed ex) { out = rh.createExceptionReply(); CannotProceedHelper.write(out, ex); } catch (InvalidName ex) { out = rh.createExceptionReply(); InvalidNameHelper.write(out, ex); } catch (AlreadyBound ex) { out = rh.createExceptionReply(); AlreadyBoundHelper.write(out, ex); } break; } case 3: // rebind_context { try { NameComponent[] a_name = NameHelper.read(in); NamingContext a_context = NamingContextHelper.read(in); rebind_context(a_name, a_context); out = rh.createReply(); } catch (NotFound ex) { out = rh.createExceptionReply(); NotFoundHelper.write(out, ex); } catch (CannotProceed ex) { out = rh.createExceptionReply(); CannotProceedHelper.write(out, ex); } catch (InvalidName ex) { out = rh.createExceptionReply(); InvalidNameHelper.write(out, ex); } break; } case 4: // resolve { try { NameComponent[] a_name = NameHelper.read(in); org.omg.CORBA.Object __result = null; __result = resolve(a_name); out = rh.createReply(); ObjectHelper.write(out, __result); } catch (NotFound ex) { out = rh.createExceptionReply(); NotFoundHelper.write(out, ex); } catch (CannotProceed ex) { out = rh.createExceptionReply(); CannotProceedHelper.write(out, ex); } catch (InvalidName ex) { out = rh.createExceptionReply(); InvalidNameHelper.write(out, ex); } break; } case 5: // unbind { try { NameComponent[] a_name = NameHelper.read(in); unbind(a_name); out = rh.createReply(); } catch (NotFound ex) { out = rh.createExceptionReply(); NotFoundHelper.write(out, ex); } catch (CannotProceed ex) { out = rh.createExceptionReply(); CannotProceedHelper.write(out, ex); } catch (InvalidName ex) { out = rh.createExceptionReply(); InvalidNameHelper.write(out, ex); } break; } case 6: // new_context { NamingContext __result = null; __result = new_context(); out = rh.createReply(); NamingContextHelper.write(out, __result); break; } case 7: // bind_new_context { try { NameComponent[] a_name = NameHelper.read(in); NamingContext __result = null; __result = bind_new_context(a_name); out = rh.createReply(); NamingContextHelper.write(out, __result); } catch (NotFound ex) { out = rh.createExceptionReply(); NotFoundHelper.write(out, ex); } catch (AlreadyBound ex) { out = rh.createExceptionReply(); AlreadyBoundHelper.write(out, ex); } catch (CannotProceed ex) { out = rh.createExceptionReply(); CannotProceedHelper.write(out, ex); } catch (InvalidName ex) { out = rh.createExceptionReply(); InvalidNameHelper.write(out, ex); } break; } case 8: // destroy { try { destroy(); out = rh.createReply(); } catch (NotEmpty ex) { out = rh.createExceptionReply(); NotEmptyHelper.write(out, ex); } break; } case 9: // list { int amount = in.read_ulong(); BindingListHolder a_list = new BindingListHolder(); BindingIteratorHolder an_iter = new BindingIteratorHolder(); list(amount, a_list, an_iter); out = rh.createReply(); BindingListHelper.write(out, a_list.value); BindingIteratorHelper.write(out, an_iter.value); break; } default: throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE); } return out; } |
public boolean equals(Object obj) { if (!(obj instanceof ActivationDesc)) { return (false); } ActivationDesc that = (ActivationDesc)obj; if (this.groupid.equals(that.groupid) && this.classname.equals(that.classname) && this.location.equals(that.location) && this.data.equals(that.data) && this.restart == that.restart) { return (true); } return (false); } | public boolean equals(Object obj) { if (obj instanceof ActivationDesc) { ActivationDesc that = (ActivationDesc) obj; return groupid.equals(that.groupid) && classname.equals(that.classname) && location.equals(that.location) && data.equals(that.data) && restart == that.restart; } else return false; } | public boolean equals(Object obj) { if (!(obj instanceof ActivationDesc)) { return (false); } ActivationDesc that = (ActivationDesc)obj; if (this.groupid.equals(that.groupid) && this.classname.equals(that.classname) && this.location.equals(that.location) && this.data.equals(that.data) && this.restart == that.restart) { return (true); } return (false);} |
public String getClassName() { return (classname); } | public String getClassName() { return classname; } | public String getClassName() { return (classname);} |
public MarshalledObject getData() { return (data); } | public MarshalledObject getData() { return data; } | public MarshalledObject getData() { return (data);} |
public ActivationGroupID getGroupID() { return (groupid); } | public ActivationGroupID getGroupID() { return groupid; } | public ActivationGroupID getGroupID() { return (groupid);} |
public String getLocation() { return (location); } | public String getLocation() { return location; } | public String getLocation() { return (location);} |
public boolean getRestartMode() { return (restart); } | public boolean getRestartMode() { return restart; } | public boolean getRestartMode() { return (restart);} |
public int hashCode() { return (groupid.hashCode() ^ classname.hashCode() ^ location.hashCode() ^ data.hashCode()); } | public int hashCode() { return groupid.hashCode() ^ classname.hashCode() ^ location.hashCode() ^ data.hashCode(); } | public int hashCode() { return (groupid.hashCode() ^ classname.hashCode() ^ location.hashCode() ^ data.hashCode());} |
Rectangle alloc = c.isValid() ? c.getBounds() : new Rectangle(c.getPreferredSize()); | Rectangle alloc = new Rectangle(0, 0, getWidth(), getHeight()); | protected int calculateBreakPosition(int p0, int p1) { Container c = getContainer(); Rectangle alloc = c.isValid() ? c.getBounds() : new Rectangle(c.getPreferredSize()); updateMetrics(); try { getDocument().getText(p0, p1 - p0, getLineBuffer()); } catch (BadLocationException ble) { // this shouldn't happen } // FIXME: Should we account for the insets of the container? if (wordWrap) return p0 + Utilities.getBreakLocation(lineBuffer, metrics, alloc.x, alloc.x + alloc.width, this, 0); else { return p0 + Utilities.getTabbedTextOffset(lineBuffer, metrics, alloc.x, alloc.x + alloc.width, this, 0); } } |
HTMLDocument document = new HTMLDocument(); | HTMLDocument document = new HTMLDocument(getStyleSheet()); | public Document createDefaultDocument() { HTMLDocument document = new HTMLDocument(); document.setParser(getParser()); return document; } |
set.removeAttributes(set); | protected void createInputAttributes(Element element, MutableAttributeSet set) { set.addAttributes(element.getAttributes()); // FIXME: Not fully implemented. } |
|
styleSheet.importStyleSheet(getClass().getResource(DEFAULT_CSS)); } | public StyleSheet getStyleSheet() { if (styleSheet == null) styleSheet = new StyleSheet(); return styleSheet; } |
|
try { loadRules(new BufferedReader(new InputStreamReader(url.openStream())), url); } catch (IOException ioe) { } | public void importStyleSheet(URL url) { try { // FIXME: Need to make sure url points to a valid CSS document. loadRules(new BufferedReader(new InputStreamReader(url.openStream())), url); } catch (IOException ioe) { // Do nothing here. } } |
|
char shortName = 0; if (justName.length() == 1) shortName = justName.charAt(0); | boolean isPlainShort = justName.length() == 1; char shortName = justName.charAt(0); | private void handleLongOption(String real, int index) throws OptionException { String option = real.substring(index); String justName = option; int eq = option.indexOf('='); if (eq != - 1) justName = option.substring(0, eq); char shortName = 0; if (justName.length() == 1) shortName = justName.charAt(0); Option found = null; for (int i = options.size() - 1; i >= 0; --i) { Option opt = (Option) options.get(i); if (justName.equals(opt.getLongName())) { found = opt; break; } if (shortName != 0 && opt.getShortName() == shortName) { found = opt; break; } } if (found == null) { String msg = MessageFormat.format(Messages.getString("Parser.Unrecognized"), //$NON-NLS-1$ new Object[] { real }); throw new OptionException(msg); } String argument = null; if (found.getTakesArgument()) { if (eq == - 1) argument = getArgument(real); else argument = option.substring(eq + 1); } else if (eq != - 1) { String msg = MessageFormat.format(Messages.getString("Parser.NoArg"), //$NON-NLS-1$ new Object[] { real.substring(0, eq + index) }); throw new OptionException(msg); } found.parsed(argument); } |
if (shortName != 0 && opt.getShortName() == shortName) | if ((isPlainShort || opt.isJoined()) && opt.getShortName() == shortName) | private void handleLongOption(String real, int index) throws OptionException { String option = real.substring(index); String justName = option; int eq = option.indexOf('='); if (eq != - 1) justName = option.substring(0, eq); char shortName = 0; if (justName.length() == 1) shortName = justName.charAt(0); Option found = null; for (int i = options.size() - 1; i >= 0; --i) { Option opt = (Option) options.get(i); if (justName.equals(opt.getLongName())) { found = opt; break; } if (shortName != 0 && opt.getShortName() == shortName) { found = opt; break; } } if (found == null) { String msg = MessageFormat.format(Messages.getString("Parser.Unrecognized"), //$NON-NLS-1$ new Object[] { real }); throw new OptionException(msg); } String argument = null; if (found.getTakesArgument()) { if (eq == - 1) argument = getArgument(real); else argument = option.substring(eq + 1); } else if (eq != - 1) { String msg = MessageFormat.format(Messages.getString("Parser.NoArg"), //$NON-NLS-1$ new Object[] { real.substring(0, eq + index) }); throw new OptionException(msg); } found.parsed(argument); } |
for (int i = 1; i < option.length(); ++i) | for (int charIndex = 1; charIndex < option.length(); ++charIndex) | private void handleShortOptions(String option) throws OptionException { for (int i = 1; i < option.length(); ++i) { handleShortOption(option.charAt(i)); } } |
handleShortOption(option.charAt(i)); | char optChar = option.charAt(charIndex); Option found = null; for (int i = options.size() - 1; i >= 0; --i) { Option opt = (Option) options.get(i); if (optChar == opt.getShortName()) { found = opt; break; } } if (found == null) { String msg = MessageFormat.format(Messages.getString("Parser.UnrecDash"), new Object[] { "" + optChar }); throw new OptionException(msg); } String argument = null; if (found.getTakesArgument()) { if (found.isJoined() && charIndex + 1 < option.length()) { argument = option.substring(charIndex + 1); charIndex = option.length(); } else argument = getArgument("-" + optChar); } found.parsed(argument); | private void handleShortOptions(String option) throws OptionException { for (int i = 1; i < option.length(); ++i) { handleShortOption(option.charAt(i)); } } |
if (option.getShortName() != 'J') | if (! option.isJoined()) | public void printHelp(PrintStream out, boolean longOnly) { // Compute maximum lengths. int maxArgLen = 0; boolean shortOptionSeen = false; Iterator it; // The first pass only looks to see if we have a short option. it = options.iterator(); while (it.hasNext()) { Option option = (Option) it.next(); if (option.getShortName() != '\0') { shortOptionSeen = true; break; } } it = options.iterator(); while (it.hasNext()) { Option option = (Option) it.next(); String argName = option.getArgumentName(); // First compute the width required for the short // option. "2" is the initial indentation. In the // GNU style we don't print an argument name for // a short option if there is also a long name for // the option. int thisArgLen = 2; if (shortOptionSeen) thisArgLen += 4; if (option.getLongName() != null) { // Handle either '-' or '--'. thisArgLen += 1 + option.getLongName().length(); if (! longOnly) ++thisArgLen; } // Add in the width of the argument name. if (argName != null) thisArgLen += 1 + argName.length(); maxArgLen = Math.max(maxArgLen, thisArgLen); } // Print the help. if (name != null) out.println(name + ":"); it = options.iterator(); while (it.hasNext()) { Option option = (Option) it.next(); String argName = option.getArgumentName(); int column = 0; if (option.getShortName() != '\0') { out.print(" -"); out.print(option.getShortName()); column += 4; if (option.getLongName() == null) { if (argName != null) { // This is a silly hack just for '-J'. We don't // support joined options in general, but this option // is filtered out before argument processing can see it. if (option.getShortName() != 'J') { out.print(' '); ++column; } out.print(argName); column += argName.length(); } out.print(" "); } else out.print(", "); column += 2; } // Indent the long option past the short options, if one // was seen. for (; column < (shortOptionSeen ? 6 : 2); ++column) out.print(' '); if (option.getLongName() != null) { out.print(longOnly ? "-" : "--"); out.print(option.getLongName()); column += (longOnly ? 1 : 2) + option.getLongName().length(); if (argName != null) { out.print(" " + argName); column += 1 + argName.length(); } } // FIXME: should have a better heuristic for padding. out.print(FILLER.substring(0, maxArgLen + 4 - column)); formatText(out, option.getDescription(), maxArgLen + 4); } } |
Unsafe.debug("loadFromBootClassArray"); | protected static void loadFromBootClassArray(VmType[] bootClasses) { int count = bootClasses.length; for (int i = 0; i < count; i++) { VmType vmClass = bootClasses[i]; String name = vmClass.name; if (vmClass.isPrimitive()) { if (name.equals("boolean")) { BooleanClass = (VmNormalClass) vmClass; } else if (name.equals("byte")) { ByteClass = (VmNormalClass) vmClass; } else if (name.equals("char")) { CharClass = (VmNormalClass) vmClass; } else if (name.equals("short")) { ShortClass = (VmNormalClass) vmClass; } else if (name.equals("int")) { IntClass = (VmNormalClass) vmClass; } else if (name.equals("float")) { FloatClass = (VmNormalClass) vmClass; } else if (name.equals("long")) { LongClass = (VmNormalClass) vmClass; } else if (name.equals("double")) { DoubleClass = (VmNormalClass) vmClass; } else if (name.equals("void")) { VoidClass = (VmNormalClass) vmClass; } } else if (vmClass.isArray()) { if (name.equals("[Z")) { BooleanArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[B")) { ByteArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[C")) { CharArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[S")) { ShortArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[I")) { IntArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[F")) { FloatArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[J")) { LongArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[D")) { DoubleArrayClass = (VmArrayClass) vmClass; } } else if (name.equals("java.lang.Object")) { ObjectClass = (VmNormalClass) vmClass; } else if (name.equals("java.lang.Cloneable")) { CloneableClass = (VmInterfaceClass) vmClass; } else if (name.equals("java.io.Serializable")) { SerializableClass = (VmInterfaceClass) vmClass; } } } |
|
(new Thread(conn)).start(); | (new RMIIncomingThread(conn, remoteHost)).start(); | public void run() { for (;serverThread != null;) { // if serverThread==null, then exit thread try {//System.out.println("Waiting for connection on " + serverPort); UnicastConnection conn = getServerConnection(); // use a thread pool to improve performance //ConnectionRunnerPool.dispatchConnection(conn); (new Thread(conn)).start(); } catch (Exception e) { e.printStackTrace(); } }} |
Thread.currentThread().sleep(100); | Thread.sleep(100); | public void connect() { failIfConnected(); if (!isSignificant(this.user)) { connectSimple(); } else { if (this.embeddedSignon) connectEmbedded(); else connectSimulated(); Runnable runnable = new Runnable() { int tryConnection; public void run() { if ((tryConnection++ < 30) && //If it is still not connected after 3 seconds, //stop with trying (session.isConnected() == false)) { try { Thread.currentThread().sleep(100); } catch (InterruptedException ex) { ; } SwingUtilities.invokeLater(this); } else { doAfterSignon(); doInitialCommand(); } } }; runnable.run(); } } |
Thread.currentThread().sleep(100); | Thread.sleep(100); | public void run() { if ((tryConnection++ < 30) && //If it is still not connected after 3 seconds, //stop with trying (session.isConnected() == false)) { try { Thread.currentThread().sleep(100); } catch (InterruptedException ex) { ; } SwingUtilities.invokeLater(this); } else { doAfterSignon(); doInitialCommand(); } } |
oout = conn.getObjectOutputStream(); | oout = conn.startObjectOutputStream(); | public void executeCall() throws Exception { byte returncode; ObjectInput oin; // signal the call when constructing try { DataOutputStream dout = conn.getDataOutputStream(); dout.write(MESSAGE_CALL); oout = conn.getObjectOutputStream(); objid.write(oout); oout.writeInt(opnum); oout.writeLong(hash); } catch(IOException ex) { throw new MarshalException("Try to write header but failed.", ex); } try { releaseOutputStream(); DataInputStream din = conn.getDataInputStream(); if (din.readByte() != MESSAGE_CALL_ACK) throw new RemoteException("Call not acked"); oin = getInputStream(); returncode = oin.readByte(); UID.read(oin); } catch(IOException ex) { throw new UnmarshalException("Try to read header but failed:", ex); } //check return code switch(returncode) { case RETURN_ACK: //it's ok return; case RETURN_NACK: Object returnobj; try { returnobj = oin.readObject(); } catch(Exception ex2) { throw new UnmarshalException ("Try to read exception object but failed", ex2); } if(!(returnobj instanceof Exception)) throw new UnmarshalException("Should be Exception type here: " + returnobj); throw (Exception)returnobj; default: throw new UnmarshalException("Invalid return code"); } } |
oin = getInputStream(); | oin = startInputStream(); | public void executeCall() throws Exception { byte returncode; ObjectInput oin; // signal the call when constructing try { DataOutputStream dout = conn.getDataOutputStream(); dout.write(MESSAGE_CALL); oout = conn.getObjectOutputStream(); objid.write(oout); oout.writeInt(opnum); oout.writeLong(hash); } catch(IOException ex) { throw new MarshalException("Try to write header but failed.", ex); } try { releaseOutputStream(); DataInputStream din = conn.getDataInputStream(); if (din.readByte() != MESSAGE_CALL_ACK) throw new RemoteException("Call not acked"); oin = getInputStream(); returncode = oin.readByte(); UID.read(oin); } catch(IOException ex) { throw new UnmarshalException("Try to read header but failed:", ex); } //check return code switch(returncode) { case RETURN_ACK: //it's ok return; case RETURN_NACK: Object returnobj; try { returnobj = oin.readObject(); } catch(Exception ex2) { throw new UnmarshalException ("Try to read exception object but failed", ex2); } if(!(returnobj instanceof Exception)) throw new UnmarshalException("Should be Exception type here: " + returnobj); throw (Exception)returnobj; default: throw new UnmarshalException("Invalid return code"); } } |
public static UID read(DataInput in) throws IOException { UID id = new UID(); id.unique = in.readInt(); id.time = in.readLong(); id.count = in.readShort(); return (id); } | public static UID read(DataInput in) throws IOException { UID uid = new UID(); uid.unique = in.readInt(); uid.time = in.readLong(); uid.count = in.readShort(); return (uid); } | public static UID read(DataInput in) throws IOException { UID id = new UID(); id.unique = in.readInt(); id.time = in.readLong(); id.count = in.readShort(); return (id);} |
rowSM.setSelectionMode(rowSM.SINGLE_SELECTION); | rowSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | private void jbInit() throws Exception { this.setTitle(LangTool.getString("spool.title")); this.setIconImage(GUIGraphicsUtils.getApplicationIcon().getImage()); this.getContentPane().add(createFilterPanel(), BorderLayout.NORTH); // get an instance of our table model stm = new SpoolTableModel(); // create a table using our custom table model spools = new JSortTable(stm); TableColumn column = null; for (int x = 0;x < stm.getColumnCount(); x++) { column = spools.getColumnModel().getColumn(x); column.setPreferredWidth(stm.getColumnPreferredSize(x)); } spools.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // create our mouse listener on the table spools.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { spools_mouseClicked(e); } public void mousePressed (MouseEvent event) { if (SwingUtilities.isRightMouseButton(event)) showPopupMenu(event); } public void mouseReleased (MouseEvent event) { if (SwingUtilities.isRightMouseButton(event)) showPopupMenu(event); } }); spools.setShowGrid(false); //Create the scroll pane and add the table to it. scrollPane = new JScrollPane(spools); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); // setup the number of rows we should be working with spools.setPreferredScrollableViewportSize( new Dimension( spools.getPreferredScrollableViewportSize().width, spools.getFontMetrics(spools.getFont()).getHeight() * 8) ); scrollPane.getViewport().setBackground(spools.getBackground()); scrollPane.setBackground(spools.getBackground()); //Setup our selection model listener rowSM = spools.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { //Ignore extra messages. if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel)e.getSource(); } }); rowSM.setSelectionMode(rowSM.SINGLE_SELECTION); this.getContentPane().add(scrollPane, BorderLayout.CENTER); status = new JLabel("0 " + LangTool.getString("spool.count")); status.setBorder(BorderFactory.createEtchedBorder()); this.getContentPane().add(status, BorderLayout.SOUTH); pack(); //Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); if (frameSize.height > screenSize.height) frameSize.height = screenSize.height; if (frameSize.width > screenSize.width) frameSize.width = screenSize.width; setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { // close the spool file list// if (splfList != null)// splfList.close(); // close the system connection if (system != null) system.disconnectAllServices(); setVisible(false); dispose(); } }); } |
public void drawImageBuffer(Graphics2D gg2d,int x, int y, int width, int height) { | public synchronized void drawImageBuffer(Graphics2D gg2d,int x, int y, int width, int height) { | public void drawImageBuffer(Graphics2D gg2d,int x, int y, int width, int height) { /** * @todo this is a hack and should be fixed at the root of the problem */ if (gg2d == null) { System.out.println(" we got a null graphic object "); return; } synchronized (lock) { gg2d.drawImage(bi.getSubimage(x,y,width,height),null,x,y); // tell waiting threads to wake up lock.notifyAll(); } } |
synchronized (lock) { | public void drawImageBuffer(Graphics2D gg2d,int x, int y, int width, int height) { /** * @todo this is a hack and should be fixed at the root of the problem */ if (gg2d == null) { System.out.println(" we got a null graphic object "); return; } synchronized (lock) { gg2d.drawImage(bi.getSubimage(x,y,width,height),null,x,y); // tell waiting threads to wake up lock.notifyAll(); } } |
|
lock.notifyAll(); } | public void drawImageBuffer(Graphics2D gg2d,int x, int y, int width, int height) { /** * @todo this is a hack and should be fixed at the root of the problem */ if (gg2d == null) { System.out.println(" we got a null graphic object "); return; } synchronized (lock) { gg2d.drawImage(bi.getSubimage(x,y,width,height),null,x,y); // tell waiting threads to wake up lock.notifyAll(); } } |
|
this.string = str; | public URI(String str) throws URISyntaxException { parseURI(str); } |
|
this.string = (String) is.readObject(); try { parseURI(this.string); } catch (URISyntaxException x) { throw new RuntimeException(x); } | private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException { } |
|
private void writeObject(ObjectOutputStream is) throws IOException | private void writeObject(ObjectOutputStream os) throws IOException | private void writeObject(ObjectOutputStream is) throws IOException { } |
if (string == null) string = toString(); os.writeObject(string); | private void writeObject(ObjectOutputStream is) throws IOException { } |
|
data[offset+3] = (byte)((value >> 32) & 0xFF); | data[offset+3] = (byte)((value >> 24) & 0xFF); | public static void set32(byte[] data, int offset, long value) { data[offset] = (byte)(value & 0xFF); data[offset+1] = (byte)((value >> 8) & 0xFF); data[offset+2] = (byte)((value >> 16) & 0xFF); data[offset+3] = (byte)((value >> 32) & 0xFF); } |
public synchronized void setData(byte[] buf) { if (buf == null) throw new NullPointerException("Null buffer"); buffer = buf; | public void setData(byte[] buf) { setData(buf, 0, buf.length); | public synchronized void setData(byte[] buf) { // This form of setData requires setLength to be called separately // and subsequently. if (buf == null) throw new NullPointerException("Null buffer"); buffer = buf; } |
super(); | this.choice = choice; | public SwingChoicePeer(Choice choice) { super(); SwingToolkit.add(choice, this); SwingToolkit.copyAwtProperties(choice, this); final int cnt = choice.getItemCount(); for (int i = 0; i < cnt; i++) { addItem(choice.getItem(i), i); } } |
return (childValue == null || !(childValue instanceof Hashtable || childValue instanceof Vector || childValue.getClass() .isArray())); | return childValue == null || !(childValue instanceof Hashtable || childValue instanceof Vector || childValue.getClass().isArray()); | public boolean isLeaf() { return (childValue == null || !(childValue instanceof Hashtable || childValue instanceof Vector || childValue.getClass() .isArray())); } |
new RegisterGroupUsage(new RegisterEntry(X86Register.ESI, JvmType.INT), new RegisterEntry(X86Register.ESI, JvmType.REFERENCE), new RegisterEntry( X86Register.ESI, JvmType.FLOAT), false) }; | }; | protected RegisterGroupUsage[] initialize() { // The order of this array determines the cost of using the // register. // The cost of a register is lower when its index in this // array is higher. return new RegisterGroupUsage[] { new RegisterGroupUsage(new RegisterEntry(X86Register.EAX, JvmType.INT), new RegisterEntry(X86Register.EAX, JvmType.REFERENCE), new RegisterEntry( X86Register.EAX, JvmType.FLOAT), false), new RegisterGroupUsage(new RegisterEntry(X86Register.EDX, JvmType.INT), new RegisterEntry(X86Register.EDX, JvmType.REFERENCE), new RegisterEntry( X86Register.EDX, JvmType.FLOAT), false), new RegisterGroupUsage(new RegisterEntry(X86Register.ECX, JvmType.INT), new RegisterEntry(X86Register.ECX, JvmType.REFERENCE), new RegisterEntry( X86Register.ECX, JvmType.FLOAT), false), new RegisterGroupUsage(new RegisterEntry(X86Register.EBX, JvmType.INT), new RegisterEntry(X86Register.EBX, JvmType.REFERENCE), new RegisterEntry( X86Register.EBX, JvmType.FLOAT), false), new RegisterGroupUsage(new RegisterEntry(X86Register.ESI, JvmType.INT), new RegisterEntry(X86Register.ESI, JvmType.REFERENCE), new RegisterEntry( X86Register.ESI, JvmType.FLOAT), false) }; // EDI always points to the statics, do not use } |
public X86RegisterPool() { | public X86RegisterPool(boolean lastFirst, int minimumRequestIndex) { this.lastFirst = lastFirst; this.minimumRequestIndex = minimumRequestIndex; | public X86RegisterPool() { this.registers = initialize(); this.regCount = registers.length; } |
this.lastRequestIndex = regCount; | public X86RegisterPool() { this.registers = initialize(); this.regCount = registers.length; } |
|
this.lastRequestIndex = regCount; | public final void reset(X86Assembler os) { boolean inuse = false; for (int i = regCount - 1; i >= 0; i--) { if (!registers[i].isFree()) { os.log("Warning: register in use" + registers[i].getUsedRegister()); inuse = true; } } if (inuse) { throw new Error("Register(s) in use"); } } |
|
if (thumbRect.contains(e.getPoint())) thumbRollover = true; else thumbRollover = false; | public void mouseMoved(MouseEvent e) { // Not interested in where the mouse // is unless it is being dragged. } |
|
return (value > scrollbar.getValue()); | return value > scrollbar.getValue(); | boolean shouldScroll(int direction) { int value; if (scrollbar.getOrientation() == HORIZONTAL) value = valueForXPosition(currentMouseX); else value = valueForYPosition(currentMouseY); if (thumbRect.contains(currentMouseX, currentMouseY)) return false; if (direction == POSITIVE_SCROLL) return (value > scrollbar.getValue()); else return (value < scrollbar.getValue()); } |
return (value < scrollbar.getValue()); | return value < scrollbar.getValue(); | boolean shouldScroll(int direction) { int value; if (scrollbar.getOrientation() == HORIZONTAL) value = valueForXPosition(currentMouseX); else value = valueForYPosition(currentMouseY); if (thumbRect.contains(currentMouseX, currentMouseY)) return false; if (direction == POSITIVE_SCROLL) return (value > scrollbar.getValue()); else return (value < scrollbar.getValue()); } |
case (JScrollBar.HORIZONTAL): | case JScrollBar.HORIZONTAL: | protected void installComponents() { int orientation = scrollbar.getOrientation(); switch (orientation) { case (JScrollBar.HORIZONTAL): incrButton = createIncreaseButton(EAST); decrButton = createDecreaseButton(WEST); break; default: incrButton = createIncreaseButton(SOUTH); decrButton = createDecreaseButton(NORTH); break; } if (incrButton != null) scrollbar.add(incrButton); if (decrButton != null) scrollbar.add(decrButton); } |
else scrollbar.setValue(scrollbar.getValue() - scrollbar.getBlockIncrement(direction)); | protected void scrollByBlock(int direction) { scrollbar.setValue(scrollbar.getValue() + scrollbar.getBlockIncrement(direction)); } |
|
else scrollbar.setValue(scrollbar.getValue() - scrollbar.getUnitIncrement(direction)); | protected void scrollByUnit(int direction) { scrollbar.setValue(scrollbar.getValue() + scrollbar.getUnitIncrement(direction)); } |
|
return ((max - min) / 2); | return (max - min) / 2; | int valueForXPosition(int xPos) { int min = scrollbar.getMinimum(); int max = scrollbar.getMaximum(); int len = trackRect.width; int value; // If the length is 0, you shouldn't be able to even see where the slider is. // This really shouldn't ever happen, but just in case, we'll return the middle. if (len == 0) return ((max - min) / 2); value = ((xPos - trackRect.x) * (max - min) / len + min); // If this isn't a legal value, then we'll have to move to one now. if (value > max) value = max; else if (value < min) value = min; return value; } |
value = ((xPos - trackRect.x) * (max - min) / len + min); | value = (xPos - trackRect.x) * (max - min) / len + min; | int valueForXPosition(int xPos) { int min = scrollbar.getMinimum(); int max = scrollbar.getMaximum(); int len = trackRect.width; int value; // If the length is 0, you shouldn't be able to even see where the slider is. // This really shouldn't ever happen, but just in case, we'll return the middle. if (len == 0) return ((max - min) / 2); value = ((xPos - trackRect.x) * (max - min) / len + min); // If this isn't a legal value, then we'll have to move to one now. if (value > max) value = max; else if (value < min) value = min; return value; } |
return ((max - min) / 2); | return (max - min) / 2; | int valueForYPosition(int yPos) { int min = scrollbar.getMinimum(); int max = scrollbar.getMaximum(); int len = trackRect.height; int value; // If the length is 0, you shouldn't be able to even see where the thumb is. // This really shouldn't ever happen, but just in case, we'll return the middle. if (len == 0) return ((max - min) / 2); value = ((yPos - trackRect.y) * (max - min) / len + min); // If this isn't a legal value, then we'll have to move to one now. if (value > max) value = max; else if (value < min) value = min; return value; } |
value = ((yPos - trackRect.y) * (max - min) / len + min); | value = (yPos - trackRect.y) * (max - min) / len + min; | int valueForYPosition(int yPos) { int min = scrollbar.getMinimum(); int max = scrollbar.getMaximum(); int len = trackRect.height; int value; // If the length is 0, you shouldn't be able to even see where the thumb is. // This really shouldn't ever happen, but just in case, we'll return the middle. if (len == 0) return ((max - min) / 2); value = ((yPos - trackRect.y) * (max - min) / len + min); // If this isn't a legal value, then we'll have to move to one now. if (value > max) value = max; else if (value < min) value = min; return value; } |
scrollListener.setDirection(POSITIVE_SCROLL); else scrollListener.setDirection(NEGATIVE_SCROLL); | scrollListener.setDirection(POSITIVE_SCROLL); else if (e.getSource() == decrButton) scrollListener.setDirection(NEGATIVE_SCROLL); scrollTimer.setDelay(100); | public void mousePressed(MouseEvent e) { scrollTimer.stop(); scrollListener.setScrollByBlock(false); if (e.getSource() == incrButton) scrollListener.setDirection(POSITIVE_SCROLL); else scrollListener.setDirection(NEGATIVE_SCROLL); scrollTimer.start(); } |
scrollTimer.setDelay(300); if (e.getSource() == incrButton) scrollByUnit(POSITIVE_SCROLL); else if (e.getSource() == decrButton) scrollByUnit(NEGATIVE_SCROLL); | public void mouseReleased(MouseEvent e) { scrollTimer.stop(); } |
|
if (value == scrollbar.getValue()) return; | public void mousePressed(MouseEvent e) { currentMouseX = e.getX(); currentMouseY = e.getY(); int value; if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL) value = valueForXPosition(currentMouseX); else value = valueForYPosition(currentMouseY); if (value == scrollbar.getValue()) return; if (! thumbRect.contains(e.getPoint())) { scrollTimer.stop(); scrollListener.setScrollByBlock(true); if (value > scrollbar.getValue()) { trackHighlight = INCREASE_HIGHLIGHT; scrollListener.setDirection(POSITIVE_SCROLL); } else { trackHighlight = DECREASE_HIGHLIGHT; scrollListener.setDirection(NEGATIVE_SCROLL); } scrollTimer.start(); } else { // We'd like to keep track of where the cursor // is inside the thumb. // This works because the scrollbar's value represents // "lower" edge of the thumb. The value at which // the cursor is at must be greater or equal // to that value. scrollbar.setValueIsAdjusting(true); offset = value - scrollbar.getValue(); } scrollbar.repaint(); } |
|
scrollTimer.stop(); if (scrollbar.getValueIsAdjusting()) scrollbar.setValueIsAdjusting(false); | scrollListener.setScrollByBlock(false); scrollbar.setValueIsAdjusting(true); | public void mouseReleased(MouseEvent e) { trackHighlight = NO_HIGHLIGHT; scrollTimer.stop(); if (scrollbar.getValueIsAdjusting()) scrollbar.setValueIsAdjusting(false); scrollbar.repaint(); } |
{ thumbRect.x = trackRect.x; thumbRect.y = trackRect.y; if (scrollbar.getOrientation() == HORIZONTAL) | protected Rectangle getThumbBounds() { int max = scrollbar.getMaximum(); int min = scrollbar.getMinimum(); int value = scrollbar.getValue(); int extent = scrollbar.getVisibleAmount(); // System.err.println(this + ".getThumbBounds()"); if (max == min) { thumbRect.x = trackRect.x; thumbRect.y = trackRect.y; if (scrollbar.getOrientation() == HORIZONTAL) { thumbRect.width = getMinimumThumbSize().width; thumbRect.height = trackRect.height; } else { thumbRect.width = trackRect.width; thumbRect.height = getMinimumThumbSize().height; } return thumbRect; } if (scrollbar.getOrientation() == HORIZONTAL) { thumbRect.x = trackRect.x; thumbRect.x += (value - min) * trackRect.width / (max - min); thumbRect.y = trackRect.y; thumbRect.width = Math.max(extent * trackRect.width / (max - min), getMinimumThumbSize().width); thumbRect.height = trackRect.height; } else { thumbRect.x = trackRect.x; thumbRect.y = trackRect.y + value * trackRect.height / (max - min); thumbRect.width = trackRect.width; thumbRect.height = Math.max(extent * trackRect.height / (max - min), getMinimumThumbSize().height); } return thumbRect; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.