rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
g.setColor(new Color(153, 153, 204)); | if (slider.isEnabled()) g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); else g.setColor(MetalLookAndFeel.getControlDisabled()); | protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) { // Note the incoming 'g' has a translation in place to get us to the // start of the tick rect already... // TODO: get color from UIManager... g.setColor(new Color(153, 153, 204)); g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength, y); } |
g.setColor(new Color(153, 153, 204)); | if (slider.isEnabled()) g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); else g.setColor(MetalLookAndFeel.getControlDisabled()); | protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) { // Note the incoming 'g' has a translation in place to get us to the // start of the tick rect already... // TODO: get color from UIManager... g.setColor(new Color(153, 153, 204)); g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength / 2); } |
g.setColor(new Color(153, 153, 204)); | if (slider.isEnabled()) g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); else g.setColor(MetalLookAndFeel.getControlDisabled()); | protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) { // Note the incoming 'g' has a translation in place to get us to the // start of the tick rect already... // TODO: get color from UIManager... g.setColor(new Color(153, 153, 204)); g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength / 2, y); } |
int xPos = xPositionForValue(slider.getValue()); int x = (slider.getInverted() ? xPos : trackRect.x); int w = (slider.getInverted() ? trackX + trackW - xPos : xPos - trackRect.x); g.setColor(MetalLookAndFeel.getControlShadow()); g.fillRect(x + 1, trackY + 1, w - 3, getTrackWidth() - 3); if (slider.isEnabled()) { g.setColor(MetalLookAndFeel.getControl()); g.drawLine(x + 1, trackY + 1, x + w - 3, trackY + 1); g.drawLine(x + 1, trackY + 1, x + 1, trackY + getTrackWidth() - 3); } | public void paintTrack(Graphics g) { if (slider.getOrientation() == JSlider.HORIZONTAL) { if (filledSlider) { // TODO: fill the track } BasicGraphicsUtils.drawEtchedRect(g, trackRect.x, trackRect.y + (trackRect.height - getTrackWidth()) / 2, trackRect.width - 1, getTrackWidth(), Color.darkGray, Color.gray, Color.darkGray, Color.white); } else { if (filledSlider) { // TODO: fill the track } BasicGraphicsUtils.drawEtchedRect(g, trackRect.x + (trackRect.width - getTrackWidth()) / 2, trackRect.y, getTrackWidth(), trackRect.height - 1, Color.darkGray, Color.gray, Color.darkGray, Color.white); } } |
|
BasicGraphicsUtils.drawEtchedRect(g, trackRect.x, trackRect.y + (trackRect.height - getTrackWidth()) / 2, trackRect.width - 1, getTrackWidth(), Color.darkGray, Color.gray, Color.darkGray, Color.white); | public void paintTrack(Graphics g) { if (slider.getOrientation() == JSlider.HORIZONTAL) { if (filledSlider) { // TODO: fill the track } BasicGraphicsUtils.drawEtchedRect(g, trackRect.x, trackRect.y + (trackRect.height - getTrackWidth()) / 2, trackRect.width - 1, getTrackWidth(), Color.darkGray, Color.gray, Color.darkGray, Color.white); } else { if (filledSlider) { // TODO: fill the track } BasicGraphicsUtils.drawEtchedRect(g, trackRect.x + (trackRect.width - getTrackWidth()) / 2, trackRect.y, getTrackWidth(), trackRect.height - 1, Color.darkGray, Color.gray, Color.darkGray, Color.white); } } |
|
int yPos = yPositionForValue(slider.getValue()); int y = (slider.getInverted() ? trackY : yPos); int h = (slider.getInverted() ? yPos - trackY : trackY + trackH - yPos); g.setColor(MetalLookAndFeel.getControlShadow()); g.fillRect(trackX + 1, y + 1, getTrackWidth() - 3, h - 3); if (slider.isEnabled()) { g.setColor(MetalLookAndFeel.getControl()); g.drawLine(trackX + 1, y + 1, trackX + trackW - 3, y + 1); g.drawLine(trackX + 1, y + 1, trackX + 1, y + h - 3); } | public void paintTrack(Graphics g) { if (slider.getOrientation() == JSlider.HORIZONTAL) { if (filledSlider) { // TODO: fill the track } BasicGraphicsUtils.drawEtchedRect(g, trackRect.x, trackRect.y + (trackRect.height - getTrackWidth()) / 2, trackRect.width - 1, getTrackWidth(), Color.darkGray, Color.gray, Color.darkGray, Color.white); } else { if (filledSlider) { // TODO: fill the track } BasicGraphicsUtils.drawEtchedRect(g, trackRect.x + (trackRect.width - getTrackWidth()) / 2, trackRect.y, getTrackWidth(), trackRect.height - 1, Color.darkGray, Color.gray, Color.darkGray, Color.white); } } |
|
BasicGraphicsUtils.drawEtchedRect(g, trackRect.x + (trackRect.width - getTrackWidth()) / 2, trackRect.y, getTrackWidth(), trackRect.height - 1, Color.darkGray, Color.gray, Color.darkGray, Color.white); | public void paintTrack(Graphics g) { if (slider.getOrientation() == JSlider.HORIZONTAL) { if (filledSlider) { // TODO: fill the track } BasicGraphicsUtils.drawEtchedRect(g, trackRect.x, trackRect.y + (trackRect.height - getTrackWidth()) / 2, trackRect.width - 1, getTrackWidth(), Color.darkGray, Color.gray, Color.darkGray, Color.white); } else { if (filledSlider) { // TODO: fill the track } BasicGraphicsUtils.drawEtchedRect(g, trackRect.x + (trackRect.width - getTrackWidth()) / 2, trackRect.y, getTrackWidth(), trackRect.height - 1, Color.darkGray, Color.gray, Color.darkGray, Color.white); } } |
|
log.info("Emitting objects "); | log("Emitting objects", Project.MSG_DEBUG); | private final void emitObjects(NativeStream os, VmArchitecture arch, Object skipMe) throws BuildException { log.info("Emitting objects "); PrintWriter debugOut = null; try { if (debug) { debugOut = new PrintWriter(new FileWriter(debugFile)); } final ObjectEmitter emitter = new ObjectEmitter(clsMgr, os, debugOut, legalInstanceClasses); final long start = System.currentTimeMillis(); int cnt = 0; int lastUnresolved = -1; int loops = 0; while (true) { loops++; compileClasses(os, arch); final Collection objectRefs = new ArrayList(os.getObjectRefs()); int unresolved = 0; // Number of unresolved references found in the following loop int emitted = 0; // Number of emitted objects in the following loop for (Iterator i = objectRefs.iterator(); i.hasNext();) { X86Stream.ObjectRef ref = (X86Stream.ObjectRef) i.next(); if (!ref.isResolved()) { final Object obj = ref.getObject(); if (!(obj instanceof Label)) { unresolved++; if (obj instanceof VmType) { ((VmType) obj).link(); } if (obj != skipMe) { emitter.emitObject(obj); emitted++; X86Stream.ObjectRef newRef = os.getObjectRef(obj); if (ref != newRef) { throw new RuntimeException("Object has changed during emitObject! type=" + obj.getClass().getName()); } if (!ref.isResolved()) { throw new RuntimeException("Unresolved reference to object " + ((obj == null) ? "null" : obj.getClass().getName())); } } } } } if (unresolved == lastUnresolved) { if ((unresolved == 0) || (skipMe != null)) { break; } } lastUnresolved = unresolved; cnt += emitted; } final long end = System.currentTimeMillis(); log.info("Emitted " + cnt + " objects, took " + (end - start) + "ms in " + loops + " loops"); if (debugOut != null) { debugOut.close(); debugOut = null; } } catch (ClassNotFoundException ex) { throw new BuildException(ex); } catch (IOException ex) { throw new BuildException(ex); } } |
log.info("Emitted " + cnt + " objects, took " + (end - start) + "ms in " + loops + " loops"); | log("Emitted " + cnt + " objects, took " + (end - start) + "ms in " + loops + " loops"); | private final void emitObjects(NativeStream os, VmArchitecture arch, Object skipMe) throws BuildException { log.info("Emitting objects "); PrintWriter debugOut = null; try { if (debug) { debugOut = new PrintWriter(new FileWriter(debugFile)); } final ObjectEmitter emitter = new ObjectEmitter(clsMgr, os, debugOut, legalInstanceClasses); final long start = System.currentTimeMillis(); int cnt = 0; int lastUnresolved = -1; int loops = 0; while (true) { loops++; compileClasses(os, arch); final Collection objectRefs = new ArrayList(os.getObjectRefs()); int unresolved = 0; // Number of unresolved references found in the following loop int emitted = 0; // Number of emitted objects in the following loop for (Iterator i = objectRefs.iterator(); i.hasNext();) { X86Stream.ObjectRef ref = (X86Stream.ObjectRef) i.next(); if (!ref.isResolved()) { final Object obj = ref.getObject(); if (!(obj instanceof Label)) { unresolved++; if (obj instanceof VmType) { ((VmType) obj).link(); } if (obj != skipMe) { emitter.emitObject(obj); emitted++; X86Stream.ObjectRef newRef = os.getObjectRef(obj); if (ref != newRef) { throw new RuntimeException("Object has changed during emitObject! type=" + obj.getClass().getName()); } if (!ref.isResolved()) { throw new RuntimeException("Unresolved reference to object " + ((obj == null) ? "null" : obj.getClass().getName())); } } } } } if (unresolved == lastUnresolved) { if ((unresolved == 0) || (skipMe != null)) { break; } } lastUnresolved = unresolved; cnt += emitted; } final long end = System.currentTimeMillis(); log.info("Emitted " + cnt + " objects, took " + (end - start) + "ms in " + loops + " loops"); if (debugOut != null) { debugOut.close(); debugOut = null; } } catch (ClassNotFoundException ex) { throw new BuildException(ex); } catch (IOException ex) { throw new BuildException(ex); } } |
log.info("Done."); | log("Done."); | public final void execute() throws BuildException { final long lmJar = jarFile.lastModified(); final long lmKernel = kernelFile.lastModified(); final long lmDest = destFile.lastModified(); final long lmPIL = getPluginListFile().lastModified(); final PluginList piList; final long lmPI; try { piList = getPluginList(); lmPI = piList.lastModified(); } catch (PluginException ex) { throw new BuildException(ex); } catch (IOException ex) { throw new BuildException(ex); } if ((lmJar < lmDest) && (lmKernel < lmDest) && (lmPIL < lmDest) && (lmPI < lmDest)) { // No need to do anything, skip return; } try { System.getProperties().setProperty(BUILDTIME_PROPERTY, "1"); // Load the plugin descriptors final PluginRegistry piRegistry; piRegistry = new PluginRegistryModel(piList.getDescriptorUrlList()); testPluginPrerequisites(piRegistry); /* Now create the processor */ final VmProcessor proc = createProcessor(); final VmArchitecture arch = proc.getArchitecture(); log("Building for " + proc.getCPUID()); clsMgr = new VmClassLoader(classesURL, proc.getArchitecture()); final NativeStream os = createNativeStream(); final Object clInitCaller = new Label("$$clInitCaller"); VmType systemClasses[] = VmType.initializeForBootImage(clsMgr); for (int i = 0; i < systemClasses.length; i++) { clsMgr.addLoadedClass(systemClasses[i].getName(), systemClasses[i]); } // First copy the native kernel file copyKernel(os); os.setObjectRef(bootHeapStart); // Setup a call to our first java method initImageHeader(os, clInitCaller, piRegistry); // Create the initial stack createInitialStack(os, initialStack, initialStackPtr); /* Now load the classes */ loadClass(VmMethodCode.class); loadClass(Unsafe.class); loadClass(VmClassLoader.class); loadClass(VmType[].class); /* Now emit the processor */ os.getObjectRef(proc); /* Let the compilers load its native symbol offsets */ final NativeCodeCompiler[] cmps = arch.getCompilers(); for (int i = 0; i < cmps.length; i++) { final NativeCodeCompiler cmp = cmps[i]; cmp.initialize(clsMgr); os.getObjectRef(cmp); } for (Iterator i = BootClasses.values().iterator(); i.hasNext();) { BootClassInfo bci = (BootClassInfo) i.next(); if (!bci.isPackage()) { clsMgr.loadClass(bci.getName(), true); } } // Load the jarfile as byte-array copyJarFile(os); // Now emit all object images to the actual image emitObjects(os, arch, clsMgr); /* Set the bootclasses */ VmType bootClasses[] = clsMgr.prepareAfterBootstrap(); os.getObjectRef(bootClasses); emitObjects(os, arch, clsMgr); // Disallow the loading of new classes clsMgr.setFailOnNewLoad(true); // Turn auto-compilation on clsMgr.setCompileRequired(); // Emit the remaining objects emitObjects(os, arch, null); /* Write static initializer code */ emitStaticInitializerCalls(os, bootClasses, clInitCaller); // This is the end of the image X86Stream.ObjectInfo dummyObjectAtEnd = os.startObject(loadClass(VmMethodCode.class)); pageAlign(os); dummyObjectAtEnd.markEnd(); os.setObjectRef(imageEnd); os.setObjectRef(bootHeapEnd); /* Link all native symbols */ linkNativeSymbols(os); // Patch multiboot header patchHeader(os); // Store the image storeImage(os); // Generate the listfile printLabels(os, bootClasses); for (int i = 0; i < cmps.length; i++) { cmps[i].dumpStatistics(); } log.info("Done."); } catch (Throwable ex) { ex.printStackTrace(); throw new BuildException(ex); } } |
add(new BootClassInfo("org.jnode.vm.MemoryBlockManager", core)); | protected void setupBootClasses() { final int core = BootClassInfo.F_ALL; //final int core = BootClassInfo.F_RESOLVEALL; final int nonCore = BootClassInfo.F_RESOLVEALL; //int nonCore = BootClassInfo.F_ALL; add(new BootClassInfo("java.lang.Class", true, core)); add(new BootClassInfo("java.lang.Object", true, core)); add(new BootClassInfo("java.lang.String", true, core)); add(new BootClassInfo("java.lang", true, nonCore)); add(new BootClassInfo("java.lang.reflect", true, nonCore)); add(new BootClassInfo("java.lang.ref", true, nonCore)); add(new BootClassInfo("org.jnode.boot", true, nonCore)); add(new BootClassInfo("org.jnode.vm.Monitor", core)); add(new BootClassInfo("org.jnode.vm.MonitorManager", core)); add(new BootClassInfo("org.jnode.vm", true, core)); add(new BootClassInfo("org.jnode.vm.classmgr", true, core)); add(new BootClassInfo("org.jnode.vm.compiler", true, nonCore)); add(new BootClassInfo("org.jnode.util", true, nonCore)); add(new BootClassInfo("java.io", true, nonCore)); add(new BootClassInfo("java.util", true, nonCore)); add(new BootClassInfo("java.util.jar", true, nonCore)); add(new BootClassInfo("java.util.zip", true, nonCore)); add(new BootClassInfo("gnu.java.io", true, nonCore)); add(new BootClassInfo("gnu.java.nio", true, nonCore)); add(new BootClassInfo("gnu.java.io.decode", true, nonCore)); add(new BootClassInfo("gnu.java.io.encode", true, nonCore)); add(new BootClassInfo("gnu.java.io.decode.Decoder8859_1", nonCore)); add(new BootClassInfo("gnu.java.io.encode.Encoder8859_1", nonCore)); } |
|
log.info("Creating image"); | log("Creating image"); | protected void storeImage(NativeStream os) throws BuildException { try { log.info("Creating image"); FileOutputStream fos = new FileOutputStream(destFile); fos.write(os.getBytes(), 0, os.getLength()); fos.close(); } catch (IOException ex) { throw new BuildException(ex); } } |
private IntItem(int kind, Register reg, int value, int local) { super(kind, reg, local); this.value = value; | IntItem(ItemFactory factory) { super(factory); | private IntItem(int kind, Register reg, int value, int local) { super(kind, reg, local); this.value = value; } |
return createConst(getValue()); | return factory.createIConst(getValue()); | protected WordItem cloneConstant() { return createConst(getValue()); } |
throw new BAD_OPERATION("Invalid enumeration code " + code); | BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code); bad.minor = Minor.PolicyType; throw bad; | public static LifespanPolicyValue from_int(int code) { try { return enume [ code ]; } catch (ArrayIndexOutOfBoundsException ex) { throw new BAD_OPERATION("Invalid enumeration code " + code); } } |
return KeyPairCodecFactory.getEncodingShortName(defaultFormat); | return FormatUtil.getEncodingShortName(defaultFormat); | public String getFormat() { return KeyPairCodecFactory.getEncodingShortName(defaultFormat); } |
if (key != null) | if (key != null && key.isValid()) | public final SelectionKey register(Selector selin, int ops, Object att) throws ClosedChannelException { if (! isOpen()) throw new ClosedChannelException(); if ((ops & ~validOps()) != 0) throw new IllegalArgumentException(); SelectionKey key = null; AbstractSelector selector = (AbstractSelector) selin; synchronized (blockingLock()) { key = locate(selector); if (key != null) { if (att != null) key.attach(att); } else { key = selector.register(this, ops, att); if (key != null) addSelectionKey(key); } } return key; } |
wnd.add(sb, BorderLayout.SOUTH); | System.out.println(wnd.getFont().getName()); System.out.println(wnd.getFont().getClass().getName()); System.out.println(wnd.getFontMetrics(wnd.getFont()).getClass().getName()); | public static void main(String[] args) throws InterruptedException { boolean useDoubleBuffer = (args.length > 0) && args[0].equals("buffer"); final Frame wnd = new Frame("AWTTest"); try { //wnd.setSize(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getSize()); wnd.setSize(600, 400); wnd.setLayout(new BorderLayout()); //wnd.setLocation(75, 50); wnd.setBackground(Color.GREEN); final List l = new List(); l.add("Item 1"); l.add("Item 2"); l.add("Item 3"); //wnd.add(l, BorderLayout.NORTH); final Button b = new Button("Hello world"); b.addActionListener(new ActionListener() { int i =0; public void actionPerformed(ActionEvent e) { System.out.println("Action performed " + e); switch(i){ case 0:{ wnd.add(new Button(String.valueOf(i)), BorderLayout.WEST); break; } case 1:{ wnd.add(new Button(String.valueOf(i)), BorderLayout.SOUTH); break; } case 2:{ wnd.add(new Button(String.valueOf(i)), BorderLayout.EAST); break; } default: b.setLabel(String.valueOf(i)); wnd.setVisible(false); } i++; wnd.validate(); } }); wnd.add(b, BorderLayout.CENTER); b.setBackground(Color.YELLOW); final Button b2 = new Button("Left"); final Scrollbar sb = new Scrollbar(Scrollbar.HORIZONTAL); final JCheckBox cb1 = new JCheckBox("Right"); wnd.add(b2, BorderLayout.WEST); b2.setBackground(Color.RED); b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Action on b2"); if (sb.getValue() + sb.getBlockIncrement() <= sb.getMaximum()) { sb.setValue(sb.getValue() + sb.getBlockIncrement()); } else { Frame f2 = new Frame("New frame"); f2.setSize(200, 100); f2.show(); } } }); wnd.add(cb1, BorderLayout.EAST); cb1.setBackground(Color.WHITE); wnd.add(sb, BorderLayout.SOUTH); wnd.show(); while (wnd.isVisible()) { Thread.sleep(500); } // Font f = wnd.getFont();// System.out.println(f.getName());// wnd.getFontMetrics(f);// for (int i = 0; i < 30; i++) {// wnd.setLocation(wnd.getX() + 5, wnd.getY() + 4);// if ((i % 10) == 0) {// cb1.setState(!cb1.getState());// Thread.sleep(2500);// } else {// if ((i % 5) == 0) {// // Intended mixing of width & height, just for the fun of the test// wnd.setSize(wnd.getHeight(), wnd.getWidth());// }// Thread.sleep(100);// }// } Thread.sleep(5000); wnd.hide(); }catch(Throwable t){ t.printStackTrace(); } finally { wnd.dispose(); } } |
AccessController.doPrivileged(this.new GetHTTPPropertiesAction()); | proxyHostname = SystemProperties.getProperty("http.proxyHost"); if (proxyHostname != null && proxyHostname.length() > 0) { String port = SystemProperties.getProperty("http.proxyPort"); if (port != null && port.length() > 0) { proxyPort = Integer.parseInt(port); } else { proxyHostname = null; proxyPort = -1; } } agent = SystemProperties.getProperty("http.agent"); String ka = SystemProperties.getProperty("http.keepAlive"); keepAlive = !(ka != null && "false".equals(ka)); | public HTTPURLConnection(URL url) throws IOException { super(url); requestHeaders = new Headers(); AccessController.doPrivileged(this.new GetHTTPPropertiesAction()); } |
String old = requestHeaders.getValue(key); if (old == null) { requestHeaders.put(key, value); } else { requestHeaders.put(key, old + "," + value); } | requestHeaders.addValue(key, value); | public void addRequestProperty(String key, String value) { super.addRequestProperty(key, value); String old = requestHeaders.getValue(key); if (old == null) { requestHeaders.put(key, value); } else { requestHeaders.put(key, old + "," + value); } } |
Iterator i = response.getHeaders().entrySet().iterator(); Map.Entry entry; int count = 1; do { if (!i.hasNext()) { return null; } entry = (Map.Entry) i.next(); count++; } while (count <= index); return (String) entry.getValue(); | return response.getHeaders().getHeaderValue(index - 1); | public String getHeaderField(int index) { if (!connected) { try { connect(); } catch (IOException e) { return null; } } if (index == 0) { return getStatusLine(response); } Iterator i = response.getHeaders().entrySet().iterator(); Map.Entry entry; int count = 1; do { if (!i.hasNext()) { return null; } entry = (Map.Entry) i.next(); count++; } while (count <= index); return (String) entry.getValue(); } |
if (index == 0) { return null; } Iterator i = response.getHeaders().entrySet().iterator(); Map.Entry entry; int count = 1; do { if (!i.hasNext()) { return null; } entry = (Map.Entry) i.next(); count++; } while (count <= index); return (String) entry.getKey(); | return response.getHeaders().getHeaderName(index - 1); | public String getHeaderFieldKey(int index) { if (!connected) { try { connect(); } catch (IOException e) { return null; } } if (index == 0) { return null; } Iterator i = response.getHeaders().entrySet().iterator(); Map.Entry entry; int count = 1; do { if (!i.hasNext()) { return null; } entry = (Map.Entry) i.next(); count++; } while (count <= index); return (String) entry.getKey(); } |
Headers headers = response.getHeaders(); LinkedHashMap ret = new LinkedHashMap(); ret.put(null, Collections.singletonList(getStatusLine(response))); for (Iterator i = headers.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); ret.put(key, Collections.singletonList(value)); } return Collections.unmodifiableMap(ret); | Map m = response.getHeaders().getAsMap(); m.put(null, Collections.singletonList(getStatusLine(response))); return Collections.unmodifiableMap(m); | public Map getHeaderFields() { if (!connected) { try { connect(); } catch (IOException e) { return null; } } Headers headers = response.getHeaders(); LinkedHashMap ret = new LinkedHashMap(); ret.put(null, Collections.singletonList(getStatusLine(response))); for (Iterator i = headers.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); ret.put(key, Collections.singletonList(value)); } return Collections.unmodifiableMap(ret); } |
return requestHeaders; | Map m = requestHeaders.getAsMap(); return Collections.unmodifiableMap(m); | public Map getRequestProperties() { if (connected) throw new IllegalStateException("Already connected"); return requestHeaders; } |
if (key == null) return null; | public String getRequestProperty(String key) { if (key == null) return null; return requestHeaders.getValue(key); } |
|
SimpleAttributeSet atts = new SimpleAttributeSet(); atts.addAttribute(StyleConstants.IconAttribute, icon); atts.addAttribute(StyleConstants.NameAttribute, StyleConstants.IconElementName); try { getDocument().insertString(getCaret().getDot(), " ", atts); } catch (BadLocationException ex) { AssertionError err = new AssertionError("Unexpected bad location"); err.initCause(ex); throw err; } | MutableAttributeSet inputAtts = getInputAttributes(); inputAtts.removeAttributes(inputAtts); StyleConstants.setIcon(inputAtts, icon); replaceSelection(" "); inputAtts.removeAttributes(inputAtts); | public void insertIcon(Icon icon) { SimpleAttributeSet atts = new SimpleAttributeSet(); atts.addAttribute(StyleConstants.IconAttribute, icon); atts.addAttribute(StyleConstants.NameAttribute, StyleConstants.IconElementName); try { getDocument().insertString(getCaret().getDot(), " ", atts); } catch (BadLocationException ex) { AssertionError err = new AssertionError("Unexpected bad location"); err.initCause(ex); throw err; } } |
Runtime.getRuntime().load(filename); | Runtime.getRuntime().load(filename, VMStackWalker.getCallingClassLoader()); | public static void load(String filename) { Runtime.getRuntime().load(filename); } |
Runtime.getRuntime().loadLibrary(libname); | Runtime.getRuntime().loadLibrary(libname, VMStackWalker.getCallingClassLoader()); | public static void loadLibrary(String libname) { Runtime.getRuntime().loadLibrary(libname); } |
return new Position() { int off = offset; | if (offset < 0 || offset > length()) throw new BadLocationException("The offset was out of the bounds of this" + " buffer", offset); | public Position createPosition(final int offset) throws BadLocationException { return new Position() { int off = offset; public int getOffset() { return off; } }; } |
public int getOffset() { return off; } }; | int mark = offset; if (offset > gapStart) mark += gapEnd - gapStart; GapContentPosition pos = new GapContentPosition(mark); int index = Collections.binarySearch(positions, pos); if (index < 0) index = -(index + 1); positions.add(index, pos); return pos; | public Position createPosition(final int offset) throws BadLocationException { return new Position() { int off = offset; public int getOffset() { return off; } }; } |
int index = Collections.binarySearch(positions, new GapContentPosition( gapEnd)); if (index < 0) { index = -(index + 1); } for (ListIterator i = positions.listIterator(index); i.hasNext();) { GapContentPosition p = (GapContentPosition) i.next(); p.mark += delta; } | protected void shiftEnd(int newSize) { char[] newBuf = (char[]) allocateArray(length() + newSize); System.arraycopy(buffer, 0, newBuf, 0, gapStart); System.arraycopy(buffer, gapEnd, newBuf, gapStart + newSize, buffer.length - gapEnd); gapEnd = gapStart + newSize; buffer = newBuf; } |
|
} | protected void shiftGap(int newGapStart) { int newGapEnd = newGapStart + (gapEnd - gapStart); if (newGapStart == gapStart) return; else if (newGapStart < gapStart) { System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart - newGapStart); gapStart = newGapStart; gapEnd = newGapEnd; } else { System.arraycopy(buffer, gapEnd, buffer, gapStart, newGapStart - gapStart); gapStart = newGapStart; gapEnd = newGapEnd; } } |
|
public boolean addValueList (ValueListInterface valueListObj) | public boolean addValueList (ValueList valueListObj) | public boolean addValueList (ValueListInterface valueListObj) { List values = valueListObj.getValues(); // do we have any new values? if (values.size() > 0) { addValueListObj(valueListObj); // append in new values to Parameter obj Iterator iter = values.iterator(); while (iter.hasNext()) { Value thisValue = ((Value) iter.next()); internalAddValue(thisValue); } return true; } else { // safety, needed? hasValueListCompactDescription = false; Log.warnln("Warning: no Values appended, ValueList empty. Parameter unchanged."); return false; } } |
cloneObj.valueListObjects.add( ((ValueListInterface) this.valueListObjects.get(i)).clone()); | cloneObj.valueListObjects.add( ((ValueList) this.valueListObjects.get(i)).clone()); | public Object clone() throws CloneNotSupportedException { BaseObjectWithValueList cloneObj = (BaseObjectWithValueList) super.clone(); cloneObj.valueListObjects = Collections.synchronizedList(new ArrayList()); int stop = this.valueListObjects.size(); for (int i = 0; i < stop; i++) { cloneObj.valueListObjects.add( ((ValueListInterface) this.valueListObjects.get(i)).clone()); } return cloneObj; } |
public JRadioButton(String text) | public JRadioButton() | public JRadioButton(String text) { this(text, null, false); } |
this(text, null, false); | this(null, null, false); | public JRadioButton(String text) { this(text, null, false); } |
public CertificateException(String msg) | public CertificateException() | public CertificateException(String msg) { super(msg); } |
super(msg); | public CertificateException(String msg) { super(msg); } |
|
if (e.getPropertyName().equals(JComboBox.ENABLED_CHANGED_PROPERTY)) | if (e.getPropertyName().equals("enabled")) | public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals(JComboBox.ENABLED_CHANGED_PROPERTY)) { arrowButton.setEnabled(comboBox.isEnabled()); if (comboBox.isEditable()) comboBox.getEditor().getEditorComponent().setEnabled(comboBox .isEnabled()); } else if (e.getPropertyName().equals(JComboBox.EDITABLE_CHANGED_PROPERTY)) { if (comboBox.isEditable()) { configureEditor(); addEditor(); } else { unconfigureEditor(); removeEditor(); } comboBox.revalidate(); comboBox.repaint(); } else if (e.getPropertyName().equals(JComboBox.MODEL_CHANGED_PROPERTY)) { // remove ListDataListener from old model and add it to new model ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue(); if (oldModel != null) oldModel.removeListDataListener(listDataListener); if ((ComboBoxModel) e.getNewValue() != null) comboBox.getModel().addListDataListener(listDataListener); } // FIXME: Need to handle changes in other bound properties. } |
else if (e.getPropertyName().equals(JComboBox.EDITABLE_CHANGED_PROPERTY)) | else if (e.getPropertyName().equals("editable")) | public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals(JComboBox.ENABLED_CHANGED_PROPERTY)) { arrowButton.setEnabled(comboBox.isEnabled()); if (comboBox.isEditable()) comboBox.getEditor().getEditorComponent().setEnabled(comboBox .isEnabled()); } else if (e.getPropertyName().equals(JComboBox.EDITABLE_CHANGED_PROPERTY)) { if (comboBox.isEditable()) { configureEditor(); addEditor(); } else { unconfigureEditor(); removeEditor(); } comboBox.revalidate(); comboBox.repaint(); } else if (e.getPropertyName().equals(JComboBox.MODEL_CHANGED_PROPERTY)) { // remove ListDataListener from old model and add it to new model ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue(); if (oldModel != null) oldModel.removeListDataListener(listDataListener); if ((ComboBoxModel) e.getNewValue() != null) comboBox.getModel().addListDataListener(listDataListener); } // FIXME: Need to handle changes in other bound properties. } |
else if (e.getPropertyName().equals(JComboBox.MODEL_CHANGED_PROPERTY)) | else if (e.getPropertyName().equals("dataModel")) | public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals(JComboBox.ENABLED_CHANGED_PROPERTY)) { arrowButton.setEnabled(comboBox.isEnabled()); if (comboBox.isEditable()) comboBox.getEditor().getEditorComponent().setEnabled(comboBox .isEnabled()); } else if (e.getPropertyName().equals(JComboBox.EDITABLE_CHANGED_PROPERTY)) { if (comboBox.isEditable()) { configureEditor(); addEditor(); } else { unconfigureEditor(); removeEditor(); } comboBox.revalidate(); comboBox.repaint(); } else if (e.getPropertyName().equals(JComboBox.MODEL_CHANGED_PROPERTY)) { // remove ListDataListener from old model and add it to new model ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue(); if (oldModel != null) oldModel.removeListDataListener(listDataListener); if ((ComboBoxModel) e.getNewValue() != null) comboBox.getModel().addListDataListener(listDataListener); } // FIXME: Need to handle changes in other bound properties. } |
if (isSpecified("-sslType")) sesProps.put(TN5250jConstants.SSL_TYPE,getParameter("-sslType")); | private void jbInit() throws Exception { this.setSize(new Dimension(400,300)); if (isSpecified("-L")) LangTool.init(parseLocale(getParameter("-L"))); else LangTool.init(); //Let's check some permissions try { System.getProperty(".java.policy"); } catch (SecurityException e) { e.printStackTrace(); TN5250jSecurityAccessDialog.showErrorMessage(e); return; } log = TN5250jLogFactory.getLogger (this.getClass()); Properties sesProps = new Properties(); log.info(" We have loaded a new one"); // Start loading properties - Host must exist sesProps.put(SESSION_HOST,getParameter("host")); if (isSpecified("-e")) sesProps.put(SESSION_TN_ENHANCED,"1"); if (isSpecified("-p")) { sesProps.put(SESSION_HOST_PORT,getParameter("-p")); }// if (isSpecified("-f",args))// propFileName = getParm("-f",args); if (isSpecified("-cp")) sesProps.put(SESSION_CODE_PAGE ,getParameter("-cp")); if (isSpecified("-gui")) sesProps.put(SESSION_USE_GUI,"1"); if (isSpecified("-132")) sesProps.put(SESSION_SCREEN_SIZE,SCREEN_SIZE_27X132_STR); else sesProps.put(SESSION_SCREEN_SIZE,SCREEN_SIZE_24X80_STR); // socks proxy host argument if (isSpecified("-sph")) { sesProps.put(SESSION_PROXY_HOST ,getParameter("-sph")); } // socks proxy port argument if (isSpecified("-spp")) sesProps.put(SESSION_PROXY_PORT ,getParameter("-spp")); // check if device name is specified if (isSpecified("-dn")) sesProps.put(SESSION_DEVICE_NAME ,getParameter("-dn")); loadSystemProperty("SESSION_CONNECT_USER"); loadSystemProperty("SESSION_CONNECT_PASSWORD"); loadSystemProperty("SESSION_CONNECT_PROGRAM"); loadSystemProperty("SESSION_CONNECT_LIBRARY"); loadSystemProperty("SESSION_CONNECT_MENU"); manager = SessionManager.instance(); final Session5250 s = manager.openSession(sesProps,"","Test Applet"); final SessionGUI gui = new SessionGUI(s);// final JTerminal jt = new JTerminal(s); this.getContentPane().add(gui); s.connect(); SwingUtilities.invokeLater(new Runnable() { public void run() {// jt.grabFocus(); gui.grabFocus(); } }); } |
|
menuBar.getMenu(i).setSelected(false); | { JMenu menu = menuBar.getMenu(i); if (menu != null) menu.setSelected(false); } | public void mouseClicked(MouseEvent e) { MenuElement[] me = menuBar.getSubElements(); for (int i = 0; i < me.length; i++) menuBar.getMenu(i).setSelected(false); } |
if (!SwingUtilities.isRightMouseButton(e) && !isSomethingBounded) start(canvas.translateStart(e.getPoint())); | if (!SwingUtilities.isRightMouseButton(e)) { if (!isSomethingBounded) start(canvas.translateStart(e.getPoint())); else { if (isSomethingBounded) { erase(); notifyRubberBandCanvas(); reset(); start(canvas.translateStart(e.getPoint())); } } } | public void mousePressed(MouseEvent e) { if (!SwingUtilities.isRightMouseButton(e) && !isSomethingBounded) start(canvas.translateStart(e.getPoint()));// System.out.println("mouse pressed rb"); } |
erase(); stop(canvas.translateEnd(e.getPoint())); draw(); notifyRubberBandCanvas(); } } | erase(); stop(canvas.translateEnd(e.getPoint())); notifyRubberBandCanvas(); draw(); notifyRubberBandCanvas(); } } | public void mouseDragged(MouseEvent e) { if(!SwingUtilities.isRightMouseButton(e) && getCanvas().canDrawRubberBand(RubberBand.this)) { erase(); stop(canvas.translateEnd(e.getPoint())); draw(); notifyRubberBandCanvas(); } } |
firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, ! paintBorder, | firePropertyChange("borderPainted", ! paintBorder, | public void setBorderPainted(boolean painted) { if (painted != paintBorder) { paintBorder = painted; firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, ! paintBorder, paintBorder); repaint(); } } // setBorderPainted() |
firePropertyChange(FLOATABLE_CHANGED_PROPERTY, ! floatable, floatable); | firePropertyChange("floatable", ! floatable, floatable); | public void setFloatable(boolean floatable) { if (floatable != this.floatable) { this.floatable = floatable; firePropertyChange(FLOATABLE_CHANGED_PROPERTY, ! floatable, floatable); } } // setFloatable() |
firePropertyChange(MARGIN_CHANGED_PROPERTY, oldMargin, this.margin); | firePropertyChange("margin", oldMargin, this.margin); | public void setMargin(Insets margin) { if ((this.margin != null && margin == null) || (this.margin == null && margin != null) || (margin != null && this.margin != null && (margin.left != this.margin.left || margin.right != this.margin.right || margin.top != this.margin.top || margin.bottom != this.margin.bottom))) { Insets oldMargin = this.margin; this.margin = margin; firePropertyChange(MARGIN_CHANGED_PROPERTY, oldMargin, this.margin); revalidate(); repaint(); } } // setMargin() |
firePropertyChange(ORIENTATION_CHANGED_PROPERTY, oldOrientation, this.orientation); | firePropertyChange("orientation", oldOrientation, this.orientation); | public void setOrientation(int orientation) { if (orientation != HORIZONTAL && orientation != VERTICAL) throw new IllegalArgumentException(orientation + " is not a legal orientation"); if (orientation != this.orientation) { int oldOrientation = this.orientation; this.orientation = orientation; firePropertyChange(ORIENTATION_CHANGED_PROPERTY, oldOrientation, this.orientation); revalidate(); repaint(); } } // setOrientation() |
firePropertyChange(ROLLOVER_CHANGED_PROPERTY, ! rollover, rollover); | firePropertyChange("rollover", ! rollover, rollover); | public void setRollover(boolean b) { if (b != rollover) { rollover = b; firePropertyChange(ROLLOVER_CHANGED_PROPERTY, ! rollover, rollover); revalidate(); repaint(); } } |
void dump() | protected void dump() | void dump() { // Climb up the hierarchy to the parent. View parent = getParent(); if (parent != null) parent.dump(); else dump(0); } |
int startIndex = getViewIndex(startOffset, Position.Bias.Forward); | int startIndex = getViewIndex(startOffset, Position.Bias.Backward); | protected void forwardUpdate(DocumentEvent.ElementChange ec, DocumentEvent ev, Shape shape, ViewFactory vf) { int count = getViewCount(); if (count > 0) { int startOffset = ev.getOffset(); int endOffset = startOffset + ev.getLength(); // FIXME: What about this bias stuff? int startIndex = getViewIndex(startOffset, Position.Bias.Forward); int endIndex = getViewIndex(endOffset, Position.Bias.Forward); int index = -1; int addLength = -1; if (ec != null) { index = ec.getIndex(); addLength = ec.getChildrenAdded().length; } if (startIndex >= 0 && endIndex >= 0) { for (int i = startIndex; i <= endIndex; i++) { // Skip newly added child views. if (index >= 0 && i >= index && i < (index+addLength)) continue; View child = getView(i); forwardUpdateToView(child, ev, shape, vf); } } } } |
protected static boolean isFree(byte data, int index) { | protected static boolean isFree(byte[] data, int index) { int byteIndex = index / 8; byte bitIndex = (byte) (index % 8); byte mask = (byte) (1 << bitIndex); | protected static boolean isFree(byte data, int index) { //byte bitIndex = (byte) (index % 8); byte mask = (byte) (1 << index); return ((data & mask) == 0)? true : false; } |
byte mask = (byte) (1 << index); return ((data & mask) == 0)? true : false; | return ((data[byteIndex] & mask) == 0)? true : false; | protected static boolean isFree(byte data, int index) { //byte bitIndex = (byte) (index % 8); byte mask = (byte) (1 << index); return ((data & mask) == 0)? true : false; } |
Rectangle oldClip = g.getClipBounds (); g.setClip (oldClip.intersection (viewBounds)); | Rectangle oldClip = g.getClipBounds(); g.setClip(portBounds); | private void paintSimple(Graphics g, JViewport v, Component view, Point pos, Rectangle viewBounds, Rectangle portBounds) { Rectangle oldClip = g.getClipBounds (); g.setClip (oldClip.intersection (viewBounds)); g.translate (-pos.x, -pos.y); try { view.paint(g); } finally { g.translate (pos.x, pos.y); g.setClip (oldClip); } } |
textComponent.setSelectedTextColor(UIManager.getColor(prefix + ".selectionForeground")); | protected void installDefaults() { Caret caret = textComponent.getCaret(); if (caret == null) { caret = createCaret(); textComponent.setCaret(caret); } Highlighter highlighter = textComponent.getHighlighter(); if (highlighter == null) textComponent.setHighlighter(createHighlighter()); String prefix = getPropertyPrefix(); LookAndFeel.installColorsAndFont(textComponent, prefix + ".background", prefix + ".foreground", prefix + ".font"); LookAndFeel.installBorder(textComponent, prefix + ".border"); textComponent.setMargin(UIManager.getInsets(prefix + ".margin")); caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate")); // Fetch the colors for enabled/disabled text components. inactiveBackground = UIManager.getColor(prefix + ".inactiveBackground"); textComponent.setDisabledTextColor (UIManager.getColor(prefix + ".inactiveForeground")); } |
|
} | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Boolean boolValue = (Boolean) value; checkBox.setSelected(boolValue.booleanValue()); return checkBox; } |
|
JCheckBox box = new BooleanCellRenderer().getCheckBox(); setDefaultEditor(Boolean.class, new DefaultCellEditor(box)); | protected void createDefaultEditors() { //FIXME: Create the editor object. } |
|
if (editorComp!=null) moveToCellBeingEdited(editorComp); repaint(); | public void doLayout() { TableColumn resizingColumn = null; int ncols = getColumnCount(); if (ncols < 1) return; int[] pref = new int[ncols]; int prefSum = 0; int rCol = -1; if (tableHeader != null) resizingColumn = tableHeader.getResizingColumn(); for (int i = 0; i < ncols; ++i) { TableColumn col = columnModel.getColumn(i); int p = col.getWidth(); pref[i] = p; prefSum += p; if (resizingColumn == col) rCol = i; } int spill = getWidth() - prefSum; if (resizingColumn != null) { TableColumn col; TableColumn [] cols; switch (getAutoResizeMode()) { case AUTO_RESIZE_LAST_COLUMN: col = columnModel.getColumn(ncols-1); col.setWidth(col.getPreferredWidth() + spill); break; case AUTO_RESIZE_NEXT_COLUMN: col = columnModel.getColumn(ncols-1); col.setWidth(col.getPreferredWidth() + spill); break; case AUTO_RESIZE_ALL_COLUMNS: cols = new TableColumn[ncols]; for (int i = 0; i < ncols; ++i) cols[i] = columnModel.getColumn(i); distributeSpill(cols, spill); break; case AUTO_RESIZE_SUBSEQUENT_COLUMNS: cols = new TableColumn[ncols]; for (int i = rCol; i < ncols; ++i) cols[i] = columnModel.getColumn(i); distributeSpill(cols, spill); break; case AUTO_RESIZE_OFF: default: int prefWidth = resizingColumn.getPreferredWidth(); resizingColumn.setWidth(prefWidth); } } else { TableColumn [] cols = new TableColumn[ncols]; for (int i = 0; i < ncols; ++i) cols[i] = columnModel.getColumn(i); distributeSpill(cols, spill); } } |
|
oldCellValue = getValueAt(row, column); | if (isEditing()) editingStopped(new ChangeEvent("editingStopped")); editingRow = row; editingColumn = column; | public boolean editCellAt (int row, int column) { oldCellValue = getValueAt(row, column); setCellEditor(getCellEditor(row, column)); editorComp = prepareEditor(cellEditor, row, column); cellEditor.addCellEditorListener(this); rowBeingEdited = row; columnBeingEdited = column; setValueAt(editorComp, row, column); ((JTextField)editorComp).requestFocusInWindow(false); editorTimer.start(); return true; } |
cellEditor.addCellEditorListener(this); rowBeingEdited = row; columnBeingEdited = column; setValueAt(editorComp, row, column); ((JTextField)editorComp).requestFocusInWindow(false); editorTimer.start(); | removeAll(); add(editorComp); moveToCellBeingEdited(editorComp); scrollRectToVisible(editorComp.getBounds()); editorComp.requestFocusInWindow(); | public boolean editCellAt (int row, int column) { oldCellValue = getValueAt(row, column); setCellEditor(getCellEditor(row, column)); editorComp = prepareEditor(cellEditor, row, column); cellEditor.addCellEditorListener(this); rowBeingEdited = row; columnBeingEdited = column; setValueAt(editorComp, row, column); ((JTextField)editorComp).requestFocusInWindow(false); editorTimer.start(); return true; } |
if (rowBeingEdited > -1 && columnBeingEdited > -1) { if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField) | if (editorComp!=null) | public void editingCanceled (ChangeEvent event) { if (rowBeingEdited > -1 && columnBeingEdited > -1) { if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField) { remove ((Component)getValueAt(rowBeingEdited, columnBeingEdited)); setValueAt(oldCellValue, rowBeingEdited, columnBeingEdited); } rowBeingEdited = -1; columnBeingEdited = -1; } editorTimer.stop(); editorComp = null; cellEditor = null; requestFocusInWindow(false); repaint(); } |
remove ((Component)getValueAt(rowBeingEdited, columnBeingEdited)); setValueAt(oldCellValue, rowBeingEdited, columnBeingEdited); } rowBeingEdited = -1; columnBeingEdited = -1; | remove(editorComp); repaint(editorComp.getBounds()); editorComp = null; | public void editingCanceled (ChangeEvent event) { if (rowBeingEdited > -1 && columnBeingEdited > -1) { if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField) { remove ((Component)getValueAt(rowBeingEdited, columnBeingEdited)); setValueAt(oldCellValue, rowBeingEdited, columnBeingEdited); } rowBeingEdited = -1; columnBeingEdited = -1; } editorTimer.stop(); editorComp = null; cellEditor = null; requestFocusInWindow(false); repaint(); } |
editorTimer.stop(); editorComp = null; cellEditor = null; requestFocusInWindow(false); repaint(); | public void editingCanceled (ChangeEvent event) { if (rowBeingEdited > -1 && columnBeingEdited > -1) { if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField) { remove ((Component)getValueAt(rowBeingEdited, columnBeingEdited)); setValueAt(oldCellValue, rowBeingEdited, columnBeingEdited); } rowBeingEdited = -1; columnBeingEdited = -1; } editorTimer.stop(); editorComp = null; cellEditor = null; requestFocusInWindow(false); repaint(); } |
|
if (rowBeingEdited > -1 && columnBeingEdited > -1) { if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField) | if (editorComp!=null) | public void editingStopped (ChangeEvent event) { if (rowBeingEdited > -1 && columnBeingEdited > -1) { if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField) { remove((Component)getValueAt(rowBeingEdited, columnBeingEdited)); setValueAt(((JTextField)editorComp).getText(), rowBeingEdited, columnBeingEdited); } rowBeingEdited = -1; columnBeingEdited = -1; } editorTimer.stop(); editorComp = null; cellEditor = null; requestFocusInWindow(false); repaint(); } |
remove((Component)getValueAt(rowBeingEdited, columnBeingEdited)); setValueAt(((JTextField)editorComp).getText(), rowBeingEdited, columnBeingEdited); } rowBeingEdited = -1; columnBeingEdited = -1; | remove(editorComp); setValueAt(cellEditor.getCellEditorValue(), editingRow, editingColumn); repaint(editorComp.getBounds()); editorComp = null; | public void editingStopped (ChangeEvent event) { if (rowBeingEdited > -1 && columnBeingEdited > -1) { if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField) { remove((Component)getValueAt(rowBeingEdited, columnBeingEdited)); setValueAt(((JTextField)editorComp).getText(), rowBeingEdited, columnBeingEdited); } rowBeingEdited = -1; columnBeingEdited = -1; } editorTimer.stop(); editorComp = null; cellEditor = null; requestFocusInWindow(false); repaint(); } |
editorTimer.stop(); editorComp = null; cellEditor = null; requestFocusInWindow(false); repaint(); | requestFocusInWindow(); | public void editingStopped (ChangeEvent event) { if (rowBeingEdited > -1 && columnBeingEdited > -1) { if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField) { remove((Component)getValueAt(rowBeingEdited, columnBeingEdited)); setValueAt(((JTextField)editorComp).getText(), rowBeingEdited, columnBeingEdited); } rowBeingEdited = -1; columnBeingEdited = -1; } editorTimer.stop(); editorComp = null; cellEditor = null; requestFocusInWindow(false); repaint(); } |
TableCellEditor r = new DefaultCellEditor(new JTextField()); | JTextField t = new TableTextField(); TableCellEditor r = new DefaultCellEditor(t); | public TableCellEditor getDefaultEditor(Class columnClass) { if (defaultEditorsByColumnClass.containsKey(columnClass)) return (TableCellEditor) defaultEditorsByColumnClass.get(columnClass); else { // FIXME: We have at least an editor for Object.class in our defaults. TableCellEditor r = new DefaultCellEditor(new JTextField()); defaultEditorsByColumnClass.put(columnClass, r); return r; } } |
int height = getRowHeight(); | int height = getRowHeight() + getRowMargin(); | public int rowAtPoint(Point point) { if (point != null) { int nrows = getRowCount(); int height = getRowHeight(); int y = point.y; for (int i = 0; i < nrows; ++i) { if (0 <= y && y < height) return i; y -= height; } } return -1; } |
for (int i = 0; i < nrows; ++i) { if (0 <= y && y < height) return i; y -= height; } | int r = y / height; if (r < 0 || r > nrows) return -1; else return r; | public int rowAtPoint(Point point) { if (point != null) { int nrows = getRowCount(); int height = getRowHeight(); int y = point.y; for (int i = 0; i < nrows; ++i) { if (0 <= y && y < height) return i; y -= height; } } return -1; } |
else | public int rowAtPoint(Point point) { if (point != null) { int nrows = getRowCount(); int height = getRowHeight(); int y = point.y; for (int i = 0; i < nrows; ++i) { if (0 <= y && y < height) return i; y -= height; } } return -1; } |
|
if (value instanceof Component) add((Component)value); | public void setValueAt(Object value, int row, int column) { if (!isCellEditable(row, column)) return; if (value instanceof Component) add((Component)value); dataModel.setValueAt(value, row, convertColumnIndexToModel(column)); } |
|
repaint(getCellRect(row, column, true)); | public void setValueAt(Object value, int row, int column) { if (!isCellEditable(row, column)) return; if (value instanceof Component) add((Component)value); dataModel.setValueAt(value, row, convertColumnIndexToModel(column)); } |
|
return -1; | return 1; | public int getHeight(ImageObserver observer) { return -1; } |
HashSet<ImageConsumer> consumers = new HashSet<ImageConsumer>(); | Set<ImageConsumer> consumers = new HashSet<ImageConsumer>(); | public ImageProducer getSource() { return new ImageProducer() { HashSet<ImageConsumer> consumers = new HashSet<ImageConsumer>(); public void addConsumer(ImageConsumer ic) { consumers.add(ic); } public boolean isConsumer(ImageConsumer ic) { return consumers.contains(ic); } public void removeConsumer(ImageConsumer ic) { consumers.remove(ic); } public void startProduction(ImageConsumer ic) { consumers.add(ic); for (ImageConsumer c : consumers) { c.imageComplete(ImageConsumer.IMAGEERROR); } } public void requestTopDownLeftRightResend(ImageConsumer ic) { startProduction(ic); } }; } |
public void addConsumer(ImageConsumer ic) { | synchronized public void addConsumer(ImageConsumer ic) { | public ImageProducer getSource() { return new ImageProducer() { HashSet<ImageConsumer> consumers = new HashSet<ImageConsumer>(); public void addConsumer(ImageConsumer ic) { consumers.add(ic); } public boolean isConsumer(ImageConsumer ic) { return consumers.contains(ic); } public void removeConsumer(ImageConsumer ic) { consumers.remove(ic); } public void startProduction(ImageConsumer ic) { consumers.add(ic); for (ImageConsumer c : consumers) { c.imageComplete(ImageConsumer.IMAGEERROR); } } public void requestTopDownLeftRightResend(ImageConsumer ic) { startProduction(ic); } }; } |
public boolean isConsumer(ImageConsumer ic) { | synchronized public boolean isConsumer(ImageConsumer ic) { | public ImageProducer getSource() { return new ImageProducer() { HashSet<ImageConsumer> consumers = new HashSet<ImageConsumer>(); public void addConsumer(ImageConsumer ic) { consumers.add(ic); } public boolean isConsumer(ImageConsumer ic) { return consumers.contains(ic); } public void removeConsumer(ImageConsumer ic) { consumers.remove(ic); } public void startProduction(ImageConsumer ic) { consumers.add(ic); for (ImageConsumer c : consumers) { c.imageComplete(ImageConsumer.IMAGEERROR); } } public void requestTopDownLeftRightResend(ImageConsumer ic) { startProduction(ic); } }; } |
public void removeConsumer(ImageConsumer ic) { | synchronized public void removeConsumer(ImageConsumer ic) { | public ImageProducer getSource() { return new ImageProducer() { HashSet<ImageConsumer> consumers = new HashSet<ImageConsumer>(); public void addConsumer(ImageConsumer ic) { consumers.add(ic); } public boolean isConsumer(ImageConsumer ic) { return consumers.contains(ic); } public void removeConsumer(ImageConsumer ic) { consumers.remove(ic); } public void startProduction(ImageConsumer ic) { consumers.add(ic); for (ImageConsumer c : consumers) { c.imageComplete(ImageConsumer.IMAGEERROR); } } public void requestTopDownLeftRightResend(ImageConsumer ic) { startProduction(ic); } }; } |
public void startProduction(ImageConsumer ic) { | synchronized public void startProduction(ImageConsumer ic) { | public ImageProducer getSource() { return new ImageProducer() { HashSet<ImageConsumer> consumers = new HashSet<ImageConsumer>(); public void addConsumer(ImageConsumer ic) { consumers.add(ic); } public boolean isConsumer(ImageConsumer ic) { return consumers.contains(ic); } public void removeConsumer(ImageConsumer ic) { consumers.remove(ic); } public void startProduction(ImageConsumer ic) { consumers.add(ic); for (ImageConsumer c : consumers) { c.imageComplete(ImageConsumer.IMAGEERROR); } } public void requestTopDownLeftRightResend(ImageConsumer ic) { startProduction(ic); } }; } |
public void addConsumer(ImageConsumer ic) { | synchronized public void addConsumer(ImageConsumer ic) { | public void addConsumer(ImageConsumer ic) { consumers.add(ic); } |
public boolean isConsumer(ImageConsumer ic) { | synchronized public boolean isConsumer(ImageConsumer ic) { | public boolean isConsumer(ImageConsumer ic) { return consumers.contains(ic); } |
public void removeConsumer(ImageConsumer ic) { | synchronized public void removeConsumer(ImageConsumer ic) { | public void removeConsumer(ImageConsumer ic) { consumers.remove(ic); } |
public void startProduction(ImageConsumer ic) { | synchronized public void startProduction(ImageConsumer ic) { | public void startProduction(ImageConsumer ic) { consumers.add(ic); for (ImageConsumer c : consumers) { c.imageComplete(ImageConsumer.IMAGEERROR); } } |
return -1; | return 1; | public int getWidth(ImageObserver observer) { return -1; } |
return null; | return getFontManager().createFont(format, stream); | public Font createFont(int format, InputStream stream) { // TODO Auto-generated method stub return null; } |
ImageProducer producer = new FilteredImageSource(this.getSource(), new ReplicateScaleFilter(width, height)); return Toolkit.getDefaultToolkit().createImage(producer); | filter = new ReplicateScaleFilter(width, height); break; case SCALE_AREA_AVERAGING: filter = new AreaAveragingScaleFilter(width, height); break; | public Image getScaledInstance(int width, int height, int flags) { switch (flags) { case SCALE_DEFAULT: case SCALE_FAST: case SCALE_REPLICATE: ImageProducer producer = new FilteredImageSource(this.getSource(), new ReplicateScaleFilter(width, height)); return Toolkit.getDefaultToolkit().createImage(producer); case SCALE_SMOOTH: case SCALE_AREA_AVERAGING: default: throw new Error("not implemented"); } } |
case SCALE_AREA_AVERAGING: | throw new Error("SCALE_SMOOTH: not implemented"); | public Image getScaledInstance(int width, int height, int flags) { switch (flags) { case SCALE_DEFAULT: case SCALE_FAST: case SCALE_REPLICATE: ImageProducer producer = new FilteredImageSource(this.getSource(), new ReplicateScaleFilter(width, height)); return Toolkit.getDefaultToolkit().createImage(producer); case SCALE_SMOOTH: case SCALE_AREA_AVERAGING: default: throw new Error("not implemented"); } } |
throw new Error("not implemented"); | throw new Error("Unknown flag or not implemented: " + flags); | public Image getScaledInstance(int width, int height, int flags) { switch (flags) { case SCALE_DEFAULT: case SCALE_FAST: case SCALE_REPLICATE: ImageProducer producer = new FilteredImageSource(this.getSource(), new ReplicateScaleFilter(width, height)); return Toolkit.getDefaultToolkit().createImage(producer); case SCALE_SMOOTH: case SCALE_AREA_AVERAGING: default: throw new Error("not implemented"); } } |
ImageProducer producer = new FilteredImageSource(getSource(), filter); return Toolkit.getDefaultToolkit().createImage(producer); | public Image getScaledInstance(int width, int height, int flags) { switch (flags) { case SCALE_DEFAULT: case SCALE_FAST: case SCALE_REPLICATE: ImageProducer producer = new FilteredImageSource(this.getSource(), new ReplicateScaleFilter(width, height)); return Toolkit.getDefaultToolkit().createImage(producer); case SCALE_SMOOTH: case SCALE_AREA_AVERAGING: default: throw new Error("not implemented"); } } |
|
public JNodeFontPeer(String name, Map attrs) { super(name, attrs); | public JNodeFontPeer(String name, int style, int size) { super(name, style, size); | public JNodeFontPeer(String name, Map attrs) { super(name, attrs); // TODO Auto-generated constructor stub } |
String taggedIndent = indent; if (writeHrefAttribute) { dataOutputWriter.write("<"+nodeName+">"); taggedIndent = ""; } | protected String basicXMLWriter ( Writer outputWriter, String strIndent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) throws java.io.IOException { // init some internals boolean writeHrefAttribute = false; OutputStream dataOutputStream = null; Writer dataOutputWriter = null; boolean niceOutput = Specification.getInstance().isPrettyXDFOutput(); String indent = ""; // get the node name String nodeName = getClassXDFNodeName(); if (newNodeNameString != null) nodeName = newNodeNameString; // indent up one indent = indent + strIndent; //open node if (niceOutput) outputWriter.write( indent); outputWriter.write("<" + nodeName ); Entity hrefObj = getHref(); XMLDataIOStyle readObj = parentArray.getXMLDataIOStyle(); // Well here decide if we need to write out to another file, // In practice the systemId may correspond to an internet URI, // and we cant always write to that (!). Its not clear under which // situations we do want to do so. :P For the time being we just // take the following 'dumb' approach. if (hrefObj != null) { String fileName = hrefObj.getSystemId(); String hrefName = hrefObj.getName(); // Some parsers return systemId with the 'file:' prefix. Java // doenst currently understand this so we need to peal it off. int index = fileName.indexOf("file:"); if (index == 0) fileName = fileName.substring(5); if(hrefName == null) { Log.errorln("Error: href object in dataCube lacks name. Data being written into metadata instead.\n"); } else if (fileName != null) { writeHrefAttribute = true; try { dataOutputStream = new FileOutputStream(fileName); } catch (IOException e) { //oops, something. is wrong, writ out to the passed in OutputStream Log.warnln("Error: cannot open file:"+fileName+" for writing. Data being written into metadata.\n"); writeHrefAttribute = false; } } else { Log.warnln("Error: href:"+hrefName+" lacks systemId, cannot write data to a separate file."); Log.warnln("Data are being written into metadata instead.\n"); writeHrefAttribute = false; } } // write data node attributes if (writeHrefAttribute) { outputWriter.write( " "+HREF_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, hrefObj.getName()); outputWriter.write( "\""); } String checksum = getChecksum(); if (checksum != null) { outputWriter.write( " "+CHECKSUM_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, checksum.toString()); outputWriter.write( "\""); } /* String encoding = getEncoding(); if (encoding != null) { outputWriter.write( " "+ENCODING_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, encoding.toString()); outputWriter.write( "\""); }*/ String compress = getCompression(); if (compress != null && dataOutputStream != null ) { outputWriter.write( " "+COMPRESSION_TYPE_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, compress.toString()); outputWriter.write( "\""); if (hrefObj == null) { Log.errorln("Cant write compressed data within the XML file (use href instead for an external file). Aborting write."); return nodeName; } // change the data outputWriter to match if (compress.equals(Constants.DATA_COMPRESSION_GZIP)) { try { dataOutputStream = new GZIPOutputStream(dataOutputStream); } catch (java.io.IOException e) { Log.errorln("Cant open compressed (GZIP) outputstream to write to an href. Aborting."); return nodeName; } } else if (compress.equals(Constants.DATA_COMPRESSION_ZIP)) { dataOutputStream = new ZipOutputStream(dataOutputStream); try { ((ZipOutputStream) dataOutputStream).putNextEntry(new ZipEntry(hrefObj.getSystemId())); // write only to the first entry for now } catch (java.io.IOException e) { Log.errorln("Cant open compressed (ZIP) outputstream to write to an href. Aborting."); return nodeName; } } else { Log.errorln("Error: cant write data with compression type:"+compress+". Ignoring request."); return nodeName; } } if (writeHrefAttribute) outputWriter.write("/>"); //we just close the data node now else outputWriter.write(">"); //end of opening code // Locator currentLocator = parentArray.createLocator(); // List axisList = parentArray.getAxes(); List axisList = readObj.getIOAxesOrder(); if (axisList == null || axisList.size() == 0) { // we dont have axes to direct the write?!?. Well, then, we // wont be writing Data to either the XML file or an Href Log.errorln("No axes defined! Cannot write data. Ignoring request."); } else { // writing Data to either the XML file or an Href // // Init important dataFormat information into arrays, this // will help speed up long writes. Each entry corresponds to // cached information about a particular dataFormat object. In // the case where no FieldAxis (e.g. Fields) exist within the array, // then we only have 1 entry in each of these arrays. String[] noDataValues; //stores the NoDataValues for the parentArray, //used in writing out when NoDataException is caught String[] formatPattern; // cache of Java Formatter patterns for correct // formatting of output values. String[] negExponentialPattern; // Stupid Java DecimalFormatter cant work properly // on exponential data, so we compensate with this. String[] intFlag; // Integer format flag int[] numOfBytes; // number of bytes each data format has. DataFormat dataFormat[] = parentArray.getDataFormatList(); if (parentArray.hasFieldAxis()) { // If we have field axis then prepare to init multiple size arrays List fields = parentArray.getFieldAxis().getFields(); int nrofDataFormats = fields.size(); noDataValues = new String[nrofDataFormats]; formatPattern = new String[nrofDataFormats]; intFlag = new String[nrofDataFormats]; negExponentialPattern = new String[nrofDataFormats]; numOfBytes = new int[nrofDataFormats]; // now assign values for (int i = 0; i < nrofDataFormats; i++) { formatPattern[i] = dataFormat[i].getFormatPattern(); numOfBytes[i] = dataFormat[i].numOfBytes(); Field field = (Field) fields.get(i); if (field != null && field.getNoDataValue() != null) noDataValues[i] = field.getNoDataValue().toString(); if (dataFormat[i] instanceof FloatDataFormat) negExponentialPattern[i] = ((FloatDataFormat) dataFormat[i]).getNegativeExponentFormatPattern(); else negExponentialPattern[i] = null; if (dataFormat[i] instanceof IntegerDataFormat) intFlag[i] = ((IntegerDataFormat) dataFormat[i]).getType(); else intFlag[i] = null; } } else { // no field axis? then only one dataFormat and we get it from the Array // init single size arrays noDataValues = new String[1]; formatPattern = new String[1]; negExponentialPattern = new String[1]; intFlag = new String[1]; numOfBytes = new int[1]; // assign values formatPattern[0] = dataFormat[0].getFormatPattern(); numOfBytes[0] = dataFormat[0].numOfBytes(); String value = (String) null; if (parentArray.getNoDataValue() != null) { value = parentArray.getNoDataValue().toString(); // this is a HACK } noDataValues[0] = value; if (dataFormat[0] instanceof FloatDataFormat) negExponentialPattern[0] = ((FloatDataFormat) dataFormat[0]).getNegativeExponentFormatPattern(); else negExponentialPattern[0] = null; if (dataFormat[0] instanceof IntegerDataFormat) intFlag[0] = ((IntegerDataFormat) dataFormat[0]).getType(); else intFlag[0] = null; } // init the dataOutputWriter properly. To a file or to the same writer as the // rest of the XML metadata? if (dataOutputStream != null) { // if this exists, then we are re-directing to an outside file. // wrap the outputstream (compressed or otherwise) with bufferedWriter dataOutputWriter = new BufferedWriter(new OutputStreamWriter(dataOutputStream)); } else { // goes to same spot as meta-data, e.g. just use the XML output writer dataOutputWriter = outputWriter; } // some info about the format Object String endian = readObj.getEndian(); // now, based on outputstyle, write out the data if (readObj instanceof TaggedXMLDataIOStyle) { String[] tags = ((TaggedXMLDataIOStyle)readObj).getAxisTags(); int[] axes = getMaxDataIndex(readObj); int stop = axes.length; int[] axisLength = new int[stop]; for (int i = 0; i < stop; i++) { axisLength[i] = axes[stop - 1 - i]; } int whichTagIsFieldAxis = -1; if (parentArray.hasFieldAxis()) { for (int i = 0; i < stop; i++) { whichTagIsFieldAxis = i; AxisInterface axisObj = ((TaggedXMLDataIOStyle) readObj).getAxisByTag("d" + i); if (axisObj instanceof FieldAxis) { break; } } } Locator taggedLocator = parentArray.createLocator(); AxisInterface fastestAxis = (AxisInterface) axisList.get(0); int nrofDataFormats = dataFormat.length; writeTaggedData( dataOutputWriter, taggedLocator, indent, axisLength, tags, 0, 0, fastestAxis, noDataValues, nrofDataFormats, dataFormat, numOfBytes, formatPattern, negExponentialPattern, endian, intFlag, whichTagIsFieldAxis ); // this *shouldnt* be needed, but tests with both Java 1.2.2 and 1.3.0 // on SUN and Linux platforms show that it is. Hopefully we can remove // this in the future. dataOutputWriter.flush(); } //done dealing with with TaggedXMLDataIOSytle else { if (readObj instanceof DelimitedXMLDataIOStyle) { AxisInterface fastestAxis = (AxisInterface) axisList.get(0); writeDelimitedData( dataOutputWriter, (DelimitedXMLDataIOStyle) readObj, fastestAxis, noDataValues, dataFormat, numOfBytes, formatPattern, negExponentialPattern, endian, intFlag, writeHrefAttribute ? false : true ); } else { writeFormattedData( dataOutputWriter, (FormattedXMLDataIOStyle) readObj, noDataValues, dataFormat, numOfBytes, formatPattern, negExponentialPattern, endian, intFlag, writeHrefAttribute ? false : true ); } if (writeHrefAttribute) { try { // should work as flush() too, so no call needed here. dataOutputWriter.close(); } catch (java.io.IOException e) { Log.errorln("Cant close dataOuputStream! Aborting."); return nodeName; } } } } // finish writing data to XML/Href //close the data section appropriately if (!writeHrefAttribute && niceOutput) { outputWriter.write( Constants.NEW_LINE+indent); } // If we didnt write Href attribute, then means that data // were put into document. We need to close the open data // node appropriately. if (!writeHrefAttribute) outputWriter.write( "</" + nodeName + ">"); // if (niceOutput) // outputWriter.write( Constants.NEW_LINE); return nodeName; } |
|
indent, | taggedIndent, | protected String basicXMLWriter ( Writer outputWriter, String strIndent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) throws java.io.IOException { // init some internals boolean writeHrefAttribute = false; OutputStream dataOutputStream = null; Writer dataOutputWriter = null; boolean niceOutput = Specification.getInstance().isPrettyXDFOutput(); String indent = ""; // get the node name String nodeName = getClassXDFNodeName(); if (newNodeNameString != null) nodeName = newNodeNameString; // indent up one indent = indent + strIndent; //open node if (niceOutput) outputWriter.write( indent); outputWriter.write("<" + nodeName ); Entity hrefObj = getHref(); XMLDataIOStyle readObj = parentArray.getXMLDataIOStyle(); // Well here decide if we need to write out to another file, // In practice the systemId may correspond to an internet URI, // and we cant always write to that (!). Its not clear under which // situations we do want to do so. :P For the time being we just // take the following 'dumb' approach. if (hrefObj != null) { String fileName = hrefObj.getSystemId(); String hrefName = hrefObj.getName(); // Some parsers return systemId with the 'file:' prefix. Java // doenst currently understand this so we need to peal it off. int index = fileName.indexOf("file:"); if (index == 0) fileName = fileName.substring(5); if(hrefName == null) { Log.errorln("Error: href object in dataCube lacks name. Data being written into metadata instead.\n"); } else if (fileName != null) { writeHrefAttribute = true; try { dataOutputStream = new FileOutputStream(fileName); } catch (IOException e) { //oops, something. is wrong, writ out to the passed in OutputStream Log.warnln("Error: cannot open file:"+fileName+" for writing. Data being written into metadata.\n"); writeHrefAttribute = false; } } else { Log.warnln("Error: href:"+hrefName+" lacks systemId, cannot write data to a separate file."); Log.warnln("Data are being written into metadata instead.\n"); writeHrefAttribute = false; } } // write data node attributes if (writeHrefAttribute) { outputWriter.write( " "+HREF_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, hrefObj.getName()); outputWriter.write( "\""); } String checksum = getChecksum(); if (checksum != null) { outputWriter.write( " "+CHECKSUM_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, checksum.toString()); outputWriter.write( "\""); } /* String encoding = getEncoding(); if (encoding != null) { outputWriter.write( " "+ENCODING_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, encoding.toString()); outputWriter.write( "\""); }*/ String compress = getCompression(); if (compress != null && dataOutputStream != null ) { outputWriter.write( " "+COMPRESSION_TYPE_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, compress.toString()); outputWriter.write( "\""); if (hrefObj == null) { Log.errorln("Cant write compressed data within the XML file (use href instead for an external file). Aborting write."); return nodeName; } // change the data outputWriter to match if (compress.equals(Constants.DATA_COMPRESSION_GZIP)) { try { dataOutputStream = new GZIPOutputStream(dataOutputStream); } catch (java.io.IOException e) { Log.errorln("Cant open compressed (GZIP) outputstream to write to an href. Aborting."); return nodeName; } } else if (compress.equals(Constants.DATA_COMPRESSION_ZIP)) { dataOutputStream = new ZipOutputStream(dataOutputStream); try { ((ZipOutputStream) dataOutputStream).putNextEntry(new ZipEntry(hrefObj.getSystemId())); // write only to the first entry for now } catch (java.io.IOException e) { Log.errorln("Cant open compressed (ZIP) outputstream to write to an href. Aborting."); return nodeName; } } else { Log.errorln("Error: cant write data with compression type:"+compress+". Ignoring request."); return nodeName; } } if (writeHrefAttribute) outputWriter.write("/>"); //we just close the data node now else outputWriter.write(">"); //end of opening code // Locator currentLocator = parentArray.createLocator(); // List axisList = parentArray.getAxes(); List axisList = readObj.getIOAxesOrder(); if (axisList == null || axisList.size() == 0) { // we dont have axes to direct the write?!?. Well, then, we // wont be writing Data to either the XML file or an Href Log.errorln("No axes defined! Cannot write data. Ignoring request."); } else { // writing Data to either the XML file or an Href // // Init important dataFormat information into arrays, this // will help speed up long writes. Each entry corresponds to // cached information about a particular dataFormat object. In // the case where no FieldAxis (e.g. Fields) exist within the array, // then we only have 1 entry in each of these arrays. String[] noDataValues; //stores the NoDataValues for the parentArray, //used in writing out when NoDataException is caught String[] formatPattern; // cache of Java Formatter patterns for correct // formatting of output values. String[] negExponentialPattern; // Stupid Java DecimalFormatter cant work properly // on exponential data, so we compensate with this. String[] intFlag; // Integer format flag int[] numOfBytes; // number of bytes each data format has. DataFormat dataFormat[] = parentArray.getDataFormatList(); if (parentArray.hasFieldAxis()) { // If we have field axis then prepare to init multiple size arrays List fields = parentArray.getFieldAxis().getFields(); int nrofDataFormats = fields.size(); noDataValues = new String[nrofDataFormats]; formatPattern = new String[nrofDataFormats]; intFlag = new String[nrofDataFormats]; negExponentialPattern = new String[nrofDataFormats]; numOfBytes = new int[nrofDataFormats]; // now assign values for (int i = 0; i < nrofDataFormats; i++) { formatPattern[i] = dataFormat[i].getFormatPattern(); numOfBytes[i] = dataFormat[i].numOfBytes(); Field field = (Field) fields.get(i); if (field != null && field.getNoDataValue() != null) noDataValues[i] = field.getNoDataValue().toString(); if (dataFormat[i] instanceof FloatDataFormat) negExponentialPattern[i] = ((FloatDataFormat) dataFormat[i]).getNegativeExponentFormatPattern(); else negExponentialPattern[i] = null; if (dataFormat[i] instanceof IntegerDataFormat) intFlag[i] = ((IntegerDataFormat) dataFormat[i]).getType(); else intFlag[i] = null; } } else { // no field axis? then only one dataFormat and we get it from the Array // init single size arrays noDataValues = new String[1]; formatPattern = new String[1]; negExponentialPattern = new String[1]; intFlag = new String[1]; numOfBytes = new int[1]; // assign values formatPattern[0] = dataFormat[0].getFormatPattern(); numOfBytes[0] = dataFormat[0].numOfBytes(); String value = (String) null; if (parentArray.getNoDataValue() != null) { value = parentArray.getNoDataValue().toString(); // this is a HACK } noDataValues[0] = value; if (dataFormat[0] instanceof FloatDataFormat) negExponentialPattern[0] = ((FloatDataFormat) dataFormat[0]).getNegativeExponentFormatPattern(); else negExponentialPattern[0] = null; if (dataFormat[0] instanceof IntegerDataFormat) intFlag[0] = ((IntegerDataFormat) dataFormat[0]).getType(); else intFlag[0] = null; } // init the dataOutputWriter properly. To a file or to the same writer as the // rest of the XML metadata? if (dataOutputStream != null) { // if this exists, then we are re-directing to an outside file. // wrap the outputstream (compressed or otherwise) with bufferedWriter dataOutputWriter = new BufferedWriter(new OutputStreamWriter(dataOutputStream)); } else { // goes to same spot as meta-data, e.g. just use the XML output writer dataOutputWriter = outputWriter; } // some info about the format Object String endian = readObj.getEndian(); // now, based on outputstyle, write out the data if (readObj instanceof TaggedXMLDataIOStyle) { String[] tags = ((TaggedXMLDataIOStyle)readObj).getAxisTags(); int[] axes = getMaxDataIndex(readObj); int stop = axes.length; int[] axisLength = new int[stop]; for (int i = 0; i < stop; i++) { axisLength[i] = axes[stop - 1 - i]; } int whichTagIsFieldAxis = -1; if (parentArray.hasFieldAxis()) { for (int i = 0; i < stop; i++) { whichTagIsFieldAxis = i; AxisInterface axisObj = ((TaggedXMLDataIOStyle) readObj).getAxisByTag("d" + i); if (axisObj instanceof FieldAxis) { break; } } } Locator taggedLocator = parentArray.createLocator(); AxisInterface fastestAxis = (AxisInterface) axisList.get(0); int nrofDataFormats = dataFormat.length; writeTaggedData( dataOutputWriter, taggedLocator, indent, axisLength, tags, 0, 0, fastestAxis, noDataValues, nrofDataFormats, dataFormat, numOfBytes, formatPattern, negExponentialPattern, endian, intFlag, whichTagIsFieldAxis ); // this *shouldnt* be needed, but tests with both Java 1.2.2 and 1.3.0 // on SUN and Linux platforms show that it is. Hopefully we can remove // this in the future. dataOutputWriter.flush(); } //done dealing with with TaggedXMLDataIOSytle else { if (readObj instanceof DelimitedXMLDataIOStyle) { AxisInterface fastestAxis = (AxisInterface) axisList.get(0); writeDelimitedData( dataOutputWriter, (DelimitedXMLDataIOStyle) readObj, fastestAxis, noDataValues, dataFormat, numOfBytes, formatPattern, negExponentialPattern, endian, intFlag, writeHrefAttribute ? false : true ); } else { writeFormattedData( dataOutputWriter, (FormattedXMLDataIOStyle) readObj, noDataValues, dataFormat, numOfBytes, formatPattern, negExponentialPattern, endian, intFlag, writeHrefAttribute ? false : true ); } if (writeHrefAttribute) { try { // should work as flush() too, so no call needed here. dataOutputWriter.close(); } catch (java.io.IOException e) { Log.errorln("Cant close dataOuputStream! Aborting."); return nodeName; } } } } // finish writing data to XML/Href //close the data section appropriately if (!writeHrefAttribute && niceOutput) { outputWriter.write( Constants.NEW_LINE+indent); } // If we didnt write Href attribute, then means that data // were put into document. We need to close the open data // node appropriately. if (!writeHrefAttribute) outputWriter.write( "</" + nodeName + ">"); // if (niceOutput) // outputWriter.write( Constants.NEW_LINE); return nodeName; } |
if (writeHrefAttribute) { if (niceOutput) dataOutputWriter.write(Constants.NEW_LINE); dataOutputWriter.write("</"+nodeName+">"); } | protected String basicXMLWriter ( Writer outputWriter, String strIndent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) throws java.io.IOException { // init some internals boolean writeHrefAttribute = false; OutputStream dataOutputStream = null; Writer dataOutputWriter = null; boolean niceOutput = Specification.getInstance().isPrettyXDFOutput(); String indent = ""; // get the node name String nodeName = getClassXDFNodeName(); if (newNodeNameString != null) nodeName = newNodeNameString; // indent up one indent = indent + strIndent; //open node if (niceOutput) outputWriter.write( indent); outputWriter.write("<" + nodeName ); Entity hrefObj = getHref(); XMLDataIOStyle readObj = parentArray.getXMLDataIOStyle(); // Well here decide if we need to write out to another file, // In practice the systemId may correspond to an internet URI, // and we cant always write to that (!). Its not clear under which // situations we do want to do so. :P For the time being we just // take the following 'dumb' approach. if (hrefObj != null) { String fileName = hrefObj.getSystemId(); String hrefName = hrefObj.getName(); // Some parsers return systemId with the 'file:' prefix. Java // doenst currently understand this so we need to peal it off. int index = fileName.indexOf("file:"); if (index == 0) fileName = fileName.substring(5); if(hrefName == null) { Log.errorln("Error: href object in dataCube lacks name. Data being written into metadata instead.\n"); } else if (fileName != null) { writeHrefAttribute = true; try { dataOutputStream = new FileOutputStream(fileName); } catch (IOException e) { //oops, something. is wrong, writ out to the passed in OutputStream Log.warnln("Error: cannot open file:"+fileName+" for writing. Data being written into metadata.\n"); writeHrefAttribute = false; } } else { Log.warnln("Error: href:"+hrefName+" lacks systemId, cannot write data to a separate file."); Log.warnln("Data are being written into metadata instead.\n"); writeHrefAttribute = false; } } // write data node attributes if (writeHrefAttribute) { outputWriter.write( " "+HREF_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, hrefObj.getName()); outputWriter.write( "\""); } String checksum = getChecksum(); if (checksum != null) { outputWriter.write( " "+CHECKSUM_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, checksum.toString()); outputWriter.write( "\""); } /* String encoding = getEncoding(); if (encoding != null) { outputWriter.write( " "+ENCODING_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, encoding.toString()); outputWriter.write( "\""); }*/ String compress = getCompression(); if (compress != null && dataOutputStream != null ) { outputWriter.write( " "+COMPRESSION_TYPE_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputWriter, compress.toString()); outputWriter.write( "\""); if (hrefObj == null) { Log.errorln("Cant write compressed data within the XML file (use href instead for an external file). Aborting write."); return nodeName; } // change the data outputWriter to match if (compress.equals(Constants.DATA_COMPRESSION_GZIP)) { try { dataOutputStream = new GZIPOutputStream(dataOutputStream); } catch (java.io.IOException e) { Log.errorln("Cant open compressed (GZIP) outputstream to write to an href. Aborting."); return nodeName; } } else if (compress.equals(Constants.DATA_COMPRESSION_ZIP)) { dataOutputStream = new ZipOutputStream(dataOutputStream); try { ((ZipOutputStream) dataOutputStream).putNextEntry(new ZipEntry(hrefObj.getSystemId())); // write only to the first entry for now } catch (java.io.IOException e) { Log.errorln("Cant open compressed (ZIP) outputstream to write to an href. Aborting."); return nodeName; } } else { Log.errorln("Error: cant write data with compression type:"+compress+". Ignoring request."); return nodeName; } } if (writeHrefAttribute) outputWriter.write("/>"); //we just close the data node now else outputWriter.write(">"); //end of opening code // Locator currentLocator = parentArray.createLocator(); // List axisList = parentArray.getAxes(); List axisList = readObj.getIOAxesOrder(); if (axisList == null || axisList.size() == 0) { // we dont have axes to direct the write?!?. Well, then, we // wont be writing Data to either the XML file or an Href Log.errorln("No axes defined! Cannot write data. Ignoring request."); } else { // writing Data to either the XML file or an Href // // Init important dataFormat information into arrays, this // will help speed up long writes. Each entry corresponds to // cached information about a particular dataFormat object. In // the case where no FieldAxis (e.g. Fields) exist within the array, // then we only have 1 entry in each of these arrays. String[] noDataValues; //stores the NoDataValues for the parentArray, //used in writing out when NoDataException is caught String[] formatPattern; // cache of Java Formatter patterns for correct // formatting of output values. String[] negExponentialPattern; // Stupid Java DecimalFormatter cant work properly // on exponential data, so we compensate with this. String[] intFlag; // Integer format flag int[] numOfBytes; // number of bytes each data format has. DataFormat dataFormat[] = parentArray.getDataFormatList(); if (parentArray.hasFieldAxis()) { // If we have field axis then prepare to init multiple size arrays List fields = parentArray.getFieldAxis().getFields(); int nrofDataFormats = fields.size(); noDataValues = new String[nrofDataFormats]; formatPattern = new String[nrofDataFormats]; intFlag = new String[nrofDataFormats]; negExponentialPattern = new String[nrofDataFormats]; numOfBytes = new int[nrofDataFormats]; // now assign values for (int i = 0; i < nrofDataFormats; i++) { formatPattern[i] = dataFormat[i].getFormatPattern(); numOfBytes[i] = dataFormat[i].numOfBytes(); Field field = (Field) fields.get(i); if (field != null && field.getNoDataValue() != null) noDataValues[i] = field.getNoDataValue().toString(); if (dataFormat[i] instanceof FloatDataFormat) negExponentialPattern[i] = ((FloatDataFormat) dataFormat[i]).getNegativeExponentFormatPattern(); else negExponentialPattern[i] = null; if (dataFormat[i] instanceof IntegerDataFormat) intFlag[i] = ((IntegerDataFormat) dataFormat[i]).getType(); else intFlag[i] = null; } } else { // no field axis? then only one dataFormat and we get it from the Array // init single size arrays noDataValues = new String[1]; formatPattern = new String[1]; negExponentialPattern = new String[1]; intFlag = new String[1]; numOfBytes = new int[1]; // assign values formatPattern[0] = dataFormat[0].getFormatPattern(); numOfBytes[0] = dataFormat[0].numOfBytes(); String value = (String) null; if (parentArray.getNoDataValue() != null) { value = parentArray.getNoDataValue().toString(); // this is a HACK } noDataValues[0] = value; if (dataFormat[0] instanceof FloatDataFormat) negExponentialPattern[0] = ((FloatDataFormat) dataFormat[0]).getNegativeExponentFormatPattern(); else negExponentialPattern[0] = null; if (dataFormat[0] instanceof IntegerDataFormat) intFlag[0] = ((IntegerDataFormat) dataFormat[0]).getType(); else intFlag[0] = null; } // init the dataOutputWriter properly. To a file or to the same writer as the // rest of the XML metadata? if (dataOutputStream != null) { // if this exists, then we are re-directing to an outside file. // wrap the outputstream (compressed or otherwise) with bufferedWriter dataOutputWriter = new BufferedWriter(new OutputStreamWriter(dataOutputStream)); } else { // goes to same spot as meta-data, e.g. just use the XML output writer dataOutputWriter = outputWriter; } // some info about the format Object String endian = readObj.getEndian(); // now, based on outputstyle, write out the data if (readObj instanceof TaggedXMLDataIOStyle) { String[] tags = ((TaggedXMLDataIOStyle)readObj).getAxisTags(); int[] axes = getMaxDataIndex(readObj); int stop = axes.length; int[] axisLength = new int[stop]; for (int i = 0; i < stop; i++) { axisLength[i] = axes[stop - 1 - i]; } int whichTagIsFieldAxis = -1; if (parentArray.hasFieldAxis()) { for (int i = 0; i < stop; i++) { whichTagIsFieldAxis = i; AxisInterface axisObj = ((TaggedXMLDataIOStyle) readObj).getAxisByTag("d" + i); if (axisObj instanceof FieldAxis) { break; } } } Locator taggedLocator = parentArray.createLocator(); AxisInterface fastestAxis = (AxisInterface) axisList.get(0); int nrofDataFormats = dataFormat.length; writeTaggedData( dataOutputWriter, taggedLocator, indent, axisLength, tags, 0, 0, fastestAxis, noDataValues, nrofDataFormats, dataFormat, numOfBytes, formatPattern, negExponentialPattern, endian, intFlag, whichTagIsFieldAxis ); // this *shouldnt* be needed, but tests with both Java 1.2.2 and 1.3.0 // on SUN and Linux platforms show that it is. Hopefully we can remove // this in the future. dataOutputWriter.flush(); } //done dealing with with TaggedXMLDataIOSytle else { if (readObj instanceof DelimitedXMLDataIOStyle) { AxisInterface fastestAxis = (AxisInterface) axisList.get(0); writeDelimitedData( dataOutputWriter, (DelimitedXMLDataIOStyle) readObj, fastestAxis, noDataValues, dataFormat, numOfBytes, formatPattern, negExponentialPattern, endian, intFlag, writeHrefAttribute ? false : true ); } else { writeFormattedData( dataOutputWriter, (FormattedXMLDataIOStyle) readObj, noDataValues, dataFormat, numOfBytes, formatPattern, negExponentialPattern, endian, intFlag, writeHrefAttribute ? false : true ); } if (writeHrefAttribute) { try { // should work as flush() too, so no call needed here. dataOutputWriter.close(); } catch (java.io.IOException e) { Log.errorln("Cant close dataOuputStream! Aborting."); return nodeName; } } } } // finish writing data to XML/Href //close the data section appropriately if (!writeHrefAttribute && niceOutput) { outputWriter.write( Constants.NEW_LINE+indent); } // If we didnt write Href attribute, then means that data // were put into document. We need to close the open data // node appropriately. if (!writeHrefAttribute) outputWriter.write( "</" + nodeName + ">"); // if (niceOutput) // outputWriter.write( Constants.NEW_LINE); return nodeName; } |
|
ICC_ProfileRGB() | ICC_ProfileRGB(int cspace) | ICC_ProfileRGB() { super(ColorSpace.CS_sRGB); } |
super(ColorSpace.CS_sRGB); | super(cspace); matrix = createMatrix(); whitePoint = getXYZData(icSigMediaWhitePointTag); | ICC_ProfileRGB() { super(ColorSpace.CS_sRGB); } |
return 0; | short[] data; switch (component) { case REDCOMPONENT: data = getCurve(icSigRedTRCTag); break; case GREENCOMPONENT: data = getCurve(icSigGreenTRCTag); break; case BLUECOMPONENT: data = getCurve(icSigBlueTRCTag); break; default: throw new IllegalArgumentException("Not a valid component"); } if (data == null) throw new IllegalArgumentException("Error reading TRC"); if (data.length != 1) throw new ProfileDataException("Not a single-gamma TRC"); float gamma = (float) (((int) data[0] & 0xFF00) >> 8); double fraction = ((int) data[0] & 0x00FF) / 256.0; gamma += (float) fraction; return gamma; | public float getGamma(int component) { return 0; } |
return null; | float[][] mat = new float[3][3]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) mat[i][j] = matrix[i][j]; return mat; | public float[][] getMatrix() { return null; } |
return null; | short[] data; switch (component) { case REDCOMPONENT: data = getCurve(icSigRedTRCTag); break; case GREENCOMPONENT: data = getCurve(icSigGreenTRCTag); break; case BLUECOMPONENT: data = getCurve(icSigBlueTRCTag); break; default: throw new IllegalArgumentException("Not a valid component"); } if (data == null) throw new IllegalArgumentException("Error reading TRC"); if (data.length <= 1) throw new ProfileDataException("Gamma value, not a TRC table."); return data; | public short[] getTRC(int component) { return null; } |
firePropertyChange("componentOrientation", oldOrientation, o); | public void setComponentOrientation(ComponentOrientation o) { if (o == null) throw new NullPointerException(); orientation = o; } |
|
public void setDisplayedMnemonic(char mnemonic) | public void setDisplayedMnemonic(int mnemonic) | public void setDisplayedMnemonic(char mnemonic) { setDisplayedMnemonic((int) Character.toUpperCase(mnemonic)); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.