Java Forum / General / March 2008
I'm looking for someone to appraise my java code for me..
travel2light - 10 Mar 2008 05:22 GMT Hi, I need someone with professional java development experience to appraise my code for me. I am a self-taught programmer and I have reached a stage where I need to know if I have the potential to take up java development as a career. Or if it will just continue to be a stimulating hobby. This is really important to me and hopefully will save me a lot of time and effort!
I've written an application that pretty much summarises what I have learnt so far. It is a single compilable source file. It was written using a text editor. I have to admit it is not commented much, but once it is compiled it should be easy to see what it is about.
I would be so grateful to anyone who can help me to know what my potential is. I should also add that I'm not from an academic background and my grasp of maths is basic at best. The program have chosen will demonstrate the limits of my maths knowledge! Many thanks.
Michael
Roedy Green - 10 Mar 2008 07:38 GMT On Sun, 9 Mar 2008 21:22:55 -0700 (PDT), travel2light <everything2light@yahoo.co.uk> wrote, quoted or indirectly quoted someone who said :
>I would be so grateful to anyone who can help me to know what my >potential is. I should also add that I'm not from an academic >background and my grasp of maths is basic at best. The program have >chosen will demonstrate the limits of my maths knowledge! Many thanks. just post it. See http://mindprod.com/jgloss/sscce.html first --
Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
travel2light - 10 Mar 2008 16:02 GMT On 10 Mar, 06:38, Roedy Green <see_webs...@mindprod.com.invalid> wrote:
> On Sun, 9 Mar 2008 21:22:55 -0700 (PDT), travel2light > <everything2li...@yahoo.co.uk> wrote, quoted or indirectly quoted [quoted text clipped - 11 lines] > Roedy Green Canadian Mind Products > The Java Glossaryhttp://mindprod.com Okay here it is!
Actually this is another of my projects (my other one is a bit too big to post here + I don't want to give away my baby). I programmed this one using JBuilder IDE.
//_______________________________________________
// An application for view Stereophotos. Allow images to be opened directly from the users hard-drive, or remotely via a URL // Once opened Images can be resized and viewed in Parallel or Crosseyed format. // Will open images in JPEG, PNG or GIF file formats. // The Method for returning an image to the paint() method is getBufferedImage(); // Programmed using JBuilder IDE
//to compile: 'ImagesFrame.java' (this file) should be inside directory 'testingimages' //then compile from testingimages parent directory with: 'javac testingimages\ImagesFrame.java' //to run: run from testingimages parent directory with: 'java testingimages.ImagesFrame'
package testingimages;
import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; import java.net.URL;
import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.geom.AffineTransform; import java.util.EventListener;
import java.awt.Toolkit; import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.awt.Dimension;
public class ImagesFrame extends JFrame implements MouseWheelListener, KeyListener, MouseListener { JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); JMenuBar jMenuBar1 = new JMenuBar(); JMenu jMenuFile = new JMenu(); JMenuItem jMenuFileOpen = new JMenuItem(); JMenuItem jMenuFileExit = new JMenuItem(); JMenu jMenuHelp = new JMenu(); JMenuItem jMenuHelpAbout = new JMenuItem();
JLabel statusBar = new JLabel();
displayPanel displayP; JScrollPane jsp; JPanel ButtonPanel; int zInc; JMenuItem jMenuFileLoad = new JMenuItem(); JMenu jMenuEdit = new JMenu(); JMenuItem jMenuEditSwap = new JMenuItem(); JMenuItem jMenuEditNormal = new JMenuItem();
JMenuItem jMenuEditDivider = new JMenuItem(); JMenuItem jMenuEditCenter = new JMenuItem(); JMenuItem jMenuEditSize = new JMenuItem();
public int incValue = 100;
double scaleFactor = 1; JSlider jSlider1 = new JSlider(); JLabel sizeField = new JLabel(" "); JMenuItem jMenuItem1 = new JMenuItem(); JMenu jMenuResize = new JMenu(); JRadioButtonMenuItem Scale3 = new JRadioButtonMenuItem(); JRadioButtonMenuItem Scale2 = new JRadioButtonMenuItem(); JRadioButtonMenuItem Scale1 = new JRadioButtonMenuItem();
JRadioButtonMenuItem Scale4 = new JRadioButtonMenuItem(); JRadioButtonMenuItem Scale5 = new JRadioButtonMenuItem(); ButtonGroup group = new ButtonGroup(); JButton jButton1 = new JButton();
boolean controlPressed = false;
int resizeInc = 10;
/** * Application entry point. * * @param args String[] */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel(UIManager. getSystemLookAndFeelClassName()); } catch (Exception exception) { exception.printStackTrace(); } ImagesFrame frame = new ImagesFrame(); // Validate frames that have preset sizes // Pack frames that have useful preferred size info, e.g. from their layout boolean packFrame = false; if (packFrame) { frame.pack(); } else { frame.validate(); }
// Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setTitle("Stereo Photo Viewer"); frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true); } }); }
public ImagesFrame() { try { setDefaultCloseOperation(EXIT_ON_CLOSE); jbInit(); } catch (Exception exception) { exception.printStackTrace(); } }
private void jbInit() throws Exception {
this.zInc = 1; contentPane = (JPanel) getContentPane(); contentPane.setLayout(borderLayout1); setSize(new Dimension(400, 300)); setTitle("Frame Title"); statusBar.setText(" "); jMenuFile.setText("File"); jMenuFileOpen.setText("Open"); jMenuFileOpen.addActionListener(new ImagesFrame_jMenuFileOpen_ActionAdapter(this)); jMenuFileExit.setText("Exit"); jMenuFileExit.addActionListener(new ImagesFrame_jMenuFileExit_ActionAdapter(this)); jMenuHelp.setText("Help"); jMenuHelpAbout.setText("About"); //jMenuHelpAbout.addActionListener(new // ImagesFrame_jMenuHelpAbout_ActionAdapter(this)); jMenuFileLoad.setText("Load from URL"); jMenuFileLoad.addActionListener(new ImagesFrame_jMenuFileLoad_actionAdapter(this)); jMenuEdit.setText("Edit"); jMenuEditSwap.setText("Swap Left/Right"); jMenuEditSwap.addActionListener(new ImagesFrame_jMenuEditSwap_actionAdapter(this)); jMenuEditNormal.setText("Original size"); jMenuEditNormal.addActionListener(new ImagesFrame_jMenuEditNormal_actionAdapter(this)); jMenuEditDivider.setText("Show Divider"); jMenuEditDivider.addActionListener(new ImagesFrame_jMenuEditDivider_actionAdapter(this)); jMenuEditCenter.setText("Center Divider"); jMenuEditCenter.addActionListener(new ImagesFrame_jMenuEditCenter_actionAdapter(this)); jMenuEditSize.setText("Change size"); jMenuEditSize.addActionListener(new ImagesFrame_jMenuEditSize_actionAdapter(this)); sizeField.setText("sizeField"); jMenuResize.setText("Select resize algorythm"); Scale1.setText("SCALE_AREA_AVERAGING"); Scale1.addActionListener(new ImagesFrame_Scale1_actionAdapter(this)); Scale2.setText("SCALE_DEFAULT"); Scale2.addActionListener(new ImagesFrame_Scale2_actionAdapter(this)); Scale5.setText("SCALE_SMOOTH"); Scale5.addActionListener(new ImagesFrame_Scale5_actionAdapter(this)); Scale3.setText("SCALE_FAST"); Scale3.addActionListener(new ImagesFrame_Scale3_actionAdapter(this)); Scale4.setText("SCALE_REPLICATE"); Scale4.addActionListener(new ImagesFrame_Scale4_actionAdapter(this)); jButton1.setText("Original Size"); jButton1.addActionListener(new ImagesFrame_jButton1_actionAdapter(this)); jMenuBar1.add(jMenuFile); jMenuBar1.add(jMenuEdit); jMenuFile.add(jMenuFileOpen); jMenuFile.add(jMenuFileLoad); jMenuFile.add(jMenuFileExit); //jMenuBar1.add(jMenuHelp); //jMenuHelp.add(jMenuHelpAbout); setJMenuBar(jMenuBar1);
contentPane.add(statusBar, BorderLayout.SOUTH);
ButtonPanel = new JPanel(); contentPane.add(statusBar, BorderLayout.NORTH);
JTextField messageField = new JTextField(""); displayP = new displayPanel(50, 50); jsp = new JScrollPane(displayP, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.getViewport().add(displayP); contentPane.add(jsp, BorderLayout.CENTER); jMenuEdit.add(jMenuEditSwap); jMenuEdit.addSeparator(); jMenuEdit.add(jMenuEditNormal); jMenuEdit.add(jMenuEditSize); jMenuEdit.add(jMenuResize); jMenuEdit.addSeparator(); jMenuEdit.add(jMenuEditDivider); jMenuEdit.add(jMenuEditCenter); ButtonPanel.add(jButton1); ButtonPanel.add(jSlider1); ButtonPanel.add(sizeField); contentPane.add(ButtonPanel, BorderLayout.NORTH); group.add(Scale1); group.add(Scale2); group.add(Scale3); group.add(Scale4); group.add(Scale5); Scale5.setSelected(true); jMenuResize.add(Scale1); jMenuResize.add(Scale2); jMenuResize.add(Scale3); jMenuResize.add(Scale4); jMenuResize.add(Scale5);
Dimension x = Toolkit.getDefaultToolkit().getScreenSize(); this.setSize(x); this.setExtendedState(JFrame.MAXIMIZED_BOTH); initSlider();
displayP.resizing = false; incValue = jSlider1.getValue(); sizeField.setText(incValueToString()); refactor(incValue);
jSlider1.addMouseWheelListener(this);
this.addMouseListener(this); this.displayP.addMouseListener(this); this.setFocusable(true); this.addKeyListener(this); this.displayP.addKeyListener(this);
this.displayP.addMouseWheelListener(this); this.addMouseWheelListener(this);
displayP.repaint();
}
private void initSlider() { jSlider1.setSize(new Dimension(400, 20)); jSlider1.setPreferredSize(new Dimension(this.getWidth()/4, 20)); jSlider1.addChangeListener(new ImagesFrame_jSlider1_actionAdapter(this)); jSlider1.addMouseListener(new ImagesFrame_jSlider1_actionAdapter(this)); jSlider1.setMinimum(1); jSlider1.setMaximum(400);
incValue = 100; jSlider1.setValue(incValue); sizeField.setText("100%"); }
public void jSlider1_changeEvent(ChangeEvent e) {
displayP.resizing = true; incValue = jSlider1.getValue(); sizeField.setText(incValueToString()); refactor(incValue);
} public void jSlider1_mousePressed(MouseEvent e) { displayP.resizing = true; } public void jSlider1_mouseReleased(MouseEvent e) { displayP.resizing = false; incValue = jSlider1.getValue(); sizeField.setText(incValueToString()); refactor(incValue); resetScrollBars();
displayP.repaint();
}
public void resetScrollBars() { JScrollBar tempScrollV = jsp.getVerticalScrollBar(); JScrollBar tempScrollH = jsp.getHorizontalScrollBar(); tempScrollV.setValue((tempScrollV.getMaximum()- tempScrollV.getVisibleAmount())/2); tempScrollH.setValue((tempScrollH.getMaximum()- tempScrollH.getVisibleAmount())/2); }
public boolean isBiggerThanPane() { if (displayP.getBufferedImage().getWidth()> displayP.getWidth() || displayP.BufferedI.getHeight() > displayP.getHeight()) return true; else return false; }
void jMenuFileOpen_actionPerformed(ActionEvent actionEvent) {
System.gc();
FileDialog fd = new FileDialog(this); fd.show(); String f = fd.getDirectory() + fd.getFile(); Image im = null; try { im = Toolkit.getDefaultToolkit().getImage(f); displayP.waitForImage(im, this); } catch (Exception mye) { statusBar.setText(mye.toString()); }
if (im.getWidth(this) > 0) { reportImageOpened(im); displayP.repaint(); } else { statusBar.setText("Incorrect file type."); }
}
public void reportImageOpened(Image im) { statusBar.setText("Image loaded successfully."); displayP.resizing = false; displayP.swapped = false; displayP.initBufferedI(im); displayP.initMiniBufferedI(); incValue = 100; jSlider1.setValue(incValue); sizeField.setText(incValueToString()); displayP.resizing = false; refactor(incValue); resetScrollBars(); displayP.repaint(); this.resetDisplay(); }
public void resetDisplay() { int xInc = this.getWidth() + zInc; int yInc = this.getHeight() + zInc; zInc = -zInc; this.setSize(new Dimension(xInc, yInc)); this.show(); this.setFocusable(true); } /** * File | Exit action performed. * * @param actionEvent ActionEvent */ void jMenuFileExit_actionPerformed(ActionEvent actionEvent) { System.exit(0); }
/** * Help | About action performed. * * @param actionEvent ActionEvent */ /*void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) { ImagesFrame_AboutBox dlg = new ImagesFrame_AboutBox(this); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); }*/
public void jMenuFileLoad_actionPerformed(ActionEvent e) { System.gc(); String s = (String)JOptionPane.showInputDialog(this, "Enter a URL", null);
//If a string was returned, say so. if ((s != null) && (s.length() > 0)) { URL u = null; try { u = new URL(s); } catch (Exception mye) { statusBar.setText(mye.toString()); } if (u != null) { ImageIcon ii = null; try { ii = new ImageIcon(u);
} catch (Exception mye) { statusBar.setText(mye.toString()); } if (ii != null && ii.getImage().getWidth(this) > 0) { statusBar.setText("Image loaded successfully."); Image urlImage = ii.getImage(); reportImageOpened(urlImage);
} } }
}
public void centerDivider() { if (displayP.dividerVisible == true) { this.jMenuEditCenter.setEnabled(true); } }
public void jMenuEditSwap_actionPerformed(ActionEvent e) { displayP.swap(); if (displayP.swapped == false) { this.jMenuEditCenter.setEnabled(true); this.jMenuEditDivider.setEnabled(true);
} else { this.jMenuEditCenter.setEnabled(false); this.jMenuEditDivider.setEnabled(false);
} }
public void jMenuEditNormal_actionPerformed(ActionEvent e) { if (displayP.scaleFactor !=1) {
incValue = 100; jSlider1.setValue(incValue); sizeField.setText(incValueToString()); displayP.resizing = false; refactor(incValue); displayP.repaint();
} statusBar.setText("Full size (edit mode)"); }
public String incValueToString() { return ("" + incValue + "%"); }
public void jMenuEditDivider_actionPerformed(ActionEvent e) { if (this.displayP.dividerVisible == true) { this.displayP.dividerVisible = false; this.jMenuEditCenter.setEnabled(false); this.jMenuEditDivider.setText("Show Divider"); displayP.repaint(); } else { this.displayP.dividerVisible = true; this.jMenuEditDivider.setText("Hide Divider"); this.jMenuEditCenter.setEnabled(true);
displayP.repaint(); }
}
public void jMenuEditCenter_actionPerformed(ActionEvent e) { displayP.centered = true; displayP.centerDiv(); }
public void jMenuEditSize_actionPerformed(ActionEvent e) { String inputValue = JOptionPane.showInputDialog("Please enter a percentage.."); try { incValue = Integer.parseInt(inputValue); if (incValue > 400) incValue = 400; if (incValue <1) incValue = 1;
jSlider1.setValue(incValue); sizeField.setText("" + incValue); displayP.resizing = false; refactor(incValue); } catch (Exception mye) { System.out.println(mye.toString()); }
}
public void refactor(int s) { int inputValue = s;
try {
double tempSF = displayP.scaleFactor;
displayP.scaleFactor = Math.sqrt(((double) inputValue / 100));
displayP.initScaledBufferedI();
this.statusBar.setText("Reduced size view");
} catch (Exception mye) { JOptionPane.showMessageDialog(null, null, "Incorrect format", JOptionPane.ERROR_MESSAGE);
} }
public void Scale1_actionPerformed(ActionEvent e) { displayP.scaleType = Image.SCALE_AREA_AVERAGING; displayP.initScaledBufferedI(); displayP.repaint(); }
public void Scale2_actionPerformed(ActionEvent e) { displayP.scaleType = Image.SCALE_DEFAULT; displayP.initScaledBufferedI(); displayP.repaint(); }
public void Scale3_actionPerformed(ActionEvent e) { displayP.scaleType = Image.SCALE_FAST; displayP.initScaledBufferedI(); displayP.repaint(); }
public void Scale4_actionPerformed(ActionEvent e) { displayP.scaleType = Image.SCALE_REPLICATE; displayP.initScaledBufferedI(); displayP.repaint(); }
public void Scale5_actionPerformed(ActionEvent e) { displayP.scaleType = Image.SCALE_SMOOTH; displayP.initScaledBufferedI(); displayP.repaint(); }
public void jButton1_actionPerformed(ActionEvent e) { jMenuEditNormal_actionPerformed(null); }
public void mouseWheelMoved(MouseWheelEvent e) { if (controlPressed == true) { this.incValue += e.getWheelRotation() * resizeInc; if (incValue > 400) incValue = 400; if (incValue < 1) incValue = 1; displayP.resizing = true; sizeField.setText("" + incValue); jSlider1.setValue(incValue); refactor(incValue); displayP.repaint(); System.out.println("wheel turning"); }
}
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_CONTROL ) { System.out.println("" + controlPressed); controlPressed = true; }
}
public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_CONTROL) { controlPressed = false; displayP.resizing = false; incValue = jSlider1.getValue(); sizeField.setText(incValueToString()); refactor(incValue);
displayP.repaint(); }
}
public void keyTyped(KeyEvent e) { }
public void mouseClicked(MouseEvent e) { this.requestFocusInWindow(); }
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
}
class ImagesFrame_jButton1_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_jButton1_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); } }
class ImagesFrame_Scale5_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_Scale5_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.Scale5_actionPerformed(e); } }
class ImagesFrame_Scale4_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_Scale4_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.Scale4_actionPerformed(e); } }
class ImagesFrame_Scale3_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_Scale3_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) {
adaptee.Scale3_actionPerformed(e); } }
class ImagesFrame_Scale1_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_Scale1_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.Scale1_actionPerformed(e); } }
class ImagesFrame_jMenuEditSize_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_jMenuEditSize_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.jMenuEditSize_actionPerformed(e); } }
class ImagesFrame_Scale2_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_Scale2_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.Scale2_actionPerformed(e); } }
class ImagesFrame_jSlider1_actionAdapter implements ChangeListener, MouseListener { private ImagesFrame adaptee; ImagesFrame_jSlider1_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void stateChanged(ChangeEvent e) { adaptee.jSlider1_changeEvent(e); }
public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) { adaptee.jSlider1_mousePressed(e) ; } public void mouseReleased(MouseEvent e) { adaptee.jSlider1_mouseReleased(e) ; }
}
class ImagesFrame_jMenuEditCenter_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_jMenuEditCenter_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.jMenuEditCenter_actionPerformed(e); } }
class ImagesFrame_jMenuEditDivider_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_jMenuEditDivider_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.jMenuEditDivider_actionPerformed(e); } }
class ImagesFrame_jMenuEditNormal_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_jMenuEditNormal_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.jMenuEditNormal_actionPerformed(e); } }
class ImagesFrame_jMenuEditSwap_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_jMenuEditSwap_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.jMenuEditSwap_actionPerformed(e); } }
class ImagesFrame_jMenuFileLoad_actionAdapter implements ActionListener { private ImagesFrame adaptee; ImagesFrame_jMenuFileLoad_actionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent e) { adaptee.jMenuFileLoad_actionPerformed(e); } }
class ImagesFrame_jMenuFileOpen_ActionAdapter implements ActionListener { ImagesFrame adaptee; ImagesFrame_jMenuFileOpen_ActionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent actionEvent) { adaptee.jMenuFileOpen_actionPerformed(actionEvent); } }
class ImagesFrame_jMenuFileExit_ActionAdapter implements ActionListener { ImagesFrame adaptee;
ImagesFrame_jMenuFileExit_ActionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent actionEvent) { adaptee.jMenuFileExit_actionPerformed(actionEvent); } }
/*class ImagesFrame_jMenuHelpAbout_ActionAdapter implements ActionListener { ImagesFrame adaptee;
ImagesFrame_jMenuHelpAbout_ActionAdapter(ImagesFrame adaptee) { this.adaptee = adaptee; }
public void actionPerformed(ActionEvent actionEvent) { adaptee.jMenuHelpAbout_actionPerformed(actionEvent); } }*/
class displayPanel extends JPanel implements ImageObserver, MouseMotionListener, MouseListener{
BufferedImage BufferedI; BufferedImage ScaledBufferedI; BufferedImage MiniBufferedI; BufferedImage left; BufferedImage right; int width; int height; boolean swapped; int div = 0; int lineWidth = 2; boolean dividerVisible = false; String viewText = "Normal View"; boolean scaled = false; double scaleFactor = 1; boolean centered = true; boolean resizing = false; int scaleType = Image.SCALE_SMOOTH; int resizeFactor = 5;
public displayPanel(int w, int h) { super(); this.swapped = false; this.left = null; this.right = null; this.initBufferedI(null); this.initMiniBufferedI(); this.initScaledBufferedI(); this.addMouseMotionListener(this); this.addMouseListener(this); this.repaint(); }
public void initBufferedI(Image im) { if (im == null) { this.BufferedI = new BufferedImage(300, 200, BufferedImage.TYPE_INT_ARGB); this.drawBufferedI(); } else {
this.BufferedI = new BufferedImage(im.getWidth(this), im.getHeight(this), BufferedImage.TYPE_INT_ARGB); Graphics b2d = BufferedI.createGraphics(); b2d.drawImage(im, 0, 0, im.getWidth(this), im.getHeight(this), this); this.repaint(); } this.scaleFactor = 1; this.resizing = false; centerDiv();
}
public void initScaledBufferedI() { if (MiniBufferedI == null) { initMiniBufferedI(); } Image i = null; if (resizing == true) { i = (Image) MiniBufferedI.getScaledInstance((int) (MiniBufferedI.getWidth() * scaleFactor), (int) (MiniBufferedI.getHeight() * scaleFactor), Image.SCALE_FAST); } else { i = (Image) BufferedI.getScaledInstance((int) (BufferedI.getWidth()* scaleFactor), (int) (BufferedI.getHeight()*scaleFactor), this.scaleType);
}
waitForImage(i, this);
ScaledBufferedI = new BufferedImage(i.getWidth(this), i.getHeight(this), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = ScaledBufferedI.createGraphics();
g2d.drawImage(i, 0, 0, this);
}
//initialise Buffered Image to be used for display during resizing public void initMiniBufferedI() { Image t = null;
t = BufferedI.getScaledInstance((int) (BufferedI.getWidth() / this.resizeFactor ), (int) (BufferedI.getHeight() /this.resizeFactor), Image.SCALE_FAST); waitForImage(t, this);
MiniBufferedI = new BufferedImage(t.getWidth(this), t.getHeight(this), BufferedImage.TYPE_INT_ARGB); Graphics2D i2D = MiniBufferedI.createGraphics(); i2D.drawImage(t, null, this); }
// standard method for loading images public static boolean waitForImage(Image image, Component c) { MediaTracker tracker = new MediaTracker(c); tracker.addImage(image, 0); try { tracker.waitForAll(); } catch(InterruptedException ie) {} return(!tracker.isErrorAny()); }
public BufferedImage getBufferedImage() { if (scaleFactor == 1) { return BufferedI; } else { return ScaledBufferedI; } }
public int getCentered() { return (int)(((this.getBufferedImage().getWidth()/ 2) / scaleFactor)) ; }
public void centerDiv() { if (swapped == false) this.div = (int)(((this.getBufferedImage().getWidth()/ 2) / scaleFactor)) ;
}
public void drawBufferedI() { Graphics2D b2d = this.getBufferedImage().createGraphics(); b2d.setColor(Color.CYAN); b2d.fillRect(0, 0, getBufferedImage().getWidth(), getBufferedImage().getHeight()); b2d.setColor(Color.BLUE); b2d.drawString("No Image Loaded", 100, getBufferedImage().getHeight()/2); }
public int getDisplayX() { if (resizing == false) { return (this.getWidth() - getBufferedImage().getWidth()) / 2; } else { if (scaleFactor == 1) { return (this.getWidth() - BufferedI.getWidth()) / 2;
} else { return (this.getWidth() - (getBufferedImage().getWidth() * resizeFactor)) / 2; } } }
public int getDisplayY() { if (resizing == false) { return (this.getHeight() - getBufferedImage().getHeight()) / 2; } else { if (scaleFactor == 1) { return (this.getHeight() - BufferedI.getHeight()) / 2; } else { return (this.getHeight() - (getBufferedImage().getHeight()* resizeFactor)) / 2; } } }
public Dimension getPreferredSize() { return new Dimension(BufferedI.getWidth()*2, BufferedI.getHeight()*2); }
public void paint(Graphics g) {
if (this.BufferedI == null) { this.initBufferedI(null); } else { Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.BLACK); g2d.fillRect(0,0, this.getWidth(), this.getHeight()); g2d.setColor(Color.CYAN); if (resizing == true && scaleFactor != 1) { // Resising.. so draw a pixelated version of ScaledBufferedI for (int y = 0; y < getBufferedImage().getWidth(); y++) { for (int x = 0; x < getBufferedImage().getHeight(); x++) { int[] colArray = new int[3]; colArray = getSingleColor(y, x, getBufferedImage().getRGB(y, x)); g2d.setColor(new Color(colArray[0], colArray[1], colArray[2])); g2d.fillRect((y * resizeFactor) + getDisplayX(), (x * resizeFactor) + getDisplayY(), resizeFactor, resizeFactor); } }
} else if (resizing == true && scaleFactor == 1) { // draw BufferedI g2d.drawImage(BufferedI, null, getDisplayX(), getDisplayY()); }
else { // Draw BufferedI or ScaledBufferedI (using getBufferedImage method) g2d.drawImage(getBufferedImage(), null, getDisplayX(), getDisplayY()); }
if (dividerVisible == true && resizing == false && swapped == false) { // Draw dividing line g2d.setColor(Color.RED); g2d.fillRect(getLineX(), getLineY(), getLineWidth(), getLineHeight());
} } }
public BufferedImage drawOffscreen() { BufferedImage bi = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = bi.createGraphics();
return null; }
//standard method for extracting pixels public int[] getSingleColor(int y, int x, int pixel) { int[] retInt = new int[3]; retInt[0] = (pixel >> 16) & 0xff; //red retInt[1] = (pixel >> 8) & 0xff; //green retInt[2] = (pixel ) & 0xff; //blue return retInt;
}
public int getLineWidthOffset() { return this.lineWidth/2; }
public int getLineX() { return getDisplayX() + ((int)(getDiv()*scaleFactor) - getLineWidthOffset()); } public int getLineY() { return getDisplayY(); }
public int getLineWidth() { return this.lineWidth;
}
public int getLineHeight() { return this.getBufferedImage().getHeight(); }
public int getLineFarX() { return getLineX() + getLineWidth(); }
public int getLineFarY() { return getLineY() + getLineHeight(); }
public boolean checkIntersects(int x, int y) { if (x >= getDisplayX() && x <= getDisplayX() + getBufferedImage().getWidth()) { if (y >= getDisplayY() && y <= getDisplayY() + getBufferedImage().getHeight()) { return true; } } return false; }
public int getDiv() { return (int)((div)); }
public int getDivX() { return getDiv(); }
public int getDivLength() { return this.getBufferedImage().getWidth() - getDivX(); }
public void swap() { if (BufferedI != null) {
if (swapped == false) { swapped = true; } else { swapped = false; }
this.left = BufferedI.getSubimage(0, 0, getDivX(), BufferedI.getHeight()); this.right = BufferedI.getSubimage(getDivX(), 0, (int)(BufferedI.getWidth()-getDivX()), BufferedI.getHeight());
BufferedImage temp = new BufferedImage(BufferedI.getWidth(), BufferedI.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D tg = temp.createGraphics();
tg.drawImage(right, null, 0, 0); tg.drawImage(left, null, BufferedI.getWidth()- getDivX(), 0);
Graphics2D b2d = BufferedI.createGraphics();
b2d.drawImage(temp, null, 0, 0); this.initMiniBufferedI(); this.initScaledBufferedI(); div = BufferedI.getWidth()-getDivX(); this.repaint(); }
}
public void mouseDragged(MouseEvent e) {
int x = e.getX(); int y = e.getY(); if (checkIntersects(x, y) && swapped == false ) { centered = false; div = (int)((x - this.getDisplayX()) / scaleFactor); this.repaint(); } }
public void mouseMoved(MouseEvent e) { }
public void mouseClicked(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mousePressed(MouseEvent e) {
int x = e.getX(); int y = e.getY(); if (scaleFactor == 1 && swapped == false) { if (checkIntersects(x, y)) { div = (int) ((x - this.getDisplayX()) / scaleFactor); this.repaint(); } } }
public void mouseReleased(MouseEvent e) { }
}
//thanks for any advice!
Mark Space - 10 Mar 2008 19:33 GMT > Okay here it is! > > Actually this is another of my projects (my other one is a bit too big > to post here + I don't want to give away my baby). I programmed this > one using JBuilder IDE. If you are serious about programming in Java, you should look at the SCJD exam. If I didn't have a degree, that's what I would look at. But in general, a BS in Computer Science or something similar (Mathematics, Comp. Engeering, etc.) is going to be a requirement.
Two things struck me about the code you posted.
1. Nearly 100% lack of Javadoc comments. 2. Nearly 100% lack of logging (I didn't see any at all).
Either one of these would flunk a "real world" test from me. Code isn't just written and then forgot, it has to be maintained and debugged, sometimes in environments and by people that the original coder had no knowledge of.
Documentation and logging are your first and second lines of defense for future maintenance cycles. I think everyone would agree with me that these are absolutely fundamental to maintainable code.
A final point:
3. I didn't see any test harness.
This is also fundamental, although you may have skipped posting the test suite since it was just in one usenet post.
travel2light - 11 Mar 2008 00:52 GMT > If you are serious about programming in Java, you should look at the > SCJD exam. If I didn't have a degree, that's what I would look at. But > in general, a BS in Computer Science or something similar (Mathematics, > Comp. Engeering, etc.) is going to be a requirement. That might be out of my scope right now :-)
> Two things struck me about the code you posted. > > 1. Nearly 100% lack of Javadoc comments. > 2. Nearly 100% lack of logging (I didn't see any at all). I already discovered the importance of comments the hard way! I've been revisiting some projects I started a long time ago and I've been having a terrible time trying to make sense of them. But I've been learning a lot in the processes. Specifically as you say the need for comments but also stuff like accessing variables using methods, to make the code easier to modify.
> Either one of these would flunk a "real world" test from me. Code isn't > just written and then forgot, it has to be maintained and debugged, > sometimes in environments and by people that the original coder had no > knowledge of. I haven't got to this stage yet. But in my next project I will definitly be more thorough about my codes readability.
> Documentation and logging are your first and second lines of defense for > future maintenance cycles. I think everyone would agree with me that [quoted text clipped - 3 lines] > > 3. I didn't see any test harness. The concept of logging and a test harness are new to me. Are they connected somehow?
Michael
Mark Space - 11 Mar 2008 01:01 GMT > The concept of logging and a test harness are new to me. Are they > connected somehow? Not directly, imo. Code that is well instrumented with logging will be easy to debug when the test harness reveals an issue. However, logging is also useful in integration testing, system testing and in diagnosing problems in the field. I guess I'd say that logging goes far beyond a test harness in supporting and maintaining code.
travel2light - 11 Mar 2008 04:13 GMT > > The concept of logging and a test harness are new to me. Are they > > connected somehow? [quoted text clipped - 4 lines] > problems in the field. I guess I'd say that logging goes far beyond a > test harness in supporting and maintaining code. This is interesting thank you. It's definitely something I want to study at some point.
Arved Sandstrom - 11 Mar 2008 18:18 GMT [ SNIP ]
>> Documentation and logging are your first and second lines of defense for >> future maintenance cycles. I think everyone would agree with me that [quoted text clipped - 6 lines] > The concept of logging and a test harness are new to me. Are they > connected somehow? Logging may be done for both development/maintainability purposes (println/printf type debug statements, stack traces, writing out data structures [dumping]) or to monitor performance and security of a deployed application. Among other things. Logging should be a systematic and centrally configurable process...otherwise you may end up spending too much time maintaining your debugging code (printf's etc). Apache log4j (http://logging.apache.org/log4j/1.2/index.html) is a good example.
Test harnesses are simply software and test data that exercise some component of your code. For example, if you have created a Java class to represent a business object and the methods that operate upon it, your test harness may consist of a main class that creates the object, and invokes the methods with a set of data that test both expected and unexpected cases. These days you are rarely going to code up a test harness from scratch; JUnit (http://sourceforge.net/forum/forum.php?forum_id=717456) is a common testing framework.
As far as commenting goes, you might as well read http://en.wikipedia.org/wiki/Comment_(computer_programming). It's a reasonable overview.
AHS
Roedy Green - 12 Mar 2008 02:02 GMT On Mon, 10 Mar 2008 16:52:16 -0700 (PDT), travel2light <everything2light@yahoo.co.uk> wrote, quoted or indirectly quoted someone who said :
>I already discovered the importance of comments the hard way! I've >been revisiting some projects I started a long time ago and I've been >having a terrible time trying to make sense of them. How do you think EVERYONE finally comes to the conclusion they are of prime importance?
It is so funny the way younger programmers think we old timers are so keen on comments purely out of a sense of aesthetics. We learned through deep pain. Ditto the importance of encapsulation.
--
Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
travel2light - 12 Mar 2008 08:40 GMT On 12 Mar, 01:02, Roedy Green <see_webs...@mindprod.com.invalid> wrote:
> On Mon, 10 Mar 2008 16:52:16 -0700 (PDT), travel2light > <everything2li...@yahoo.co.uk> wrote, quoted or indirectly quoted [quoted text clipped - 15 lines] > Roedy Green Canadian Mind Products > The Java Glossaryhttp://mindprod.com It's interesting that you mention encapsulation. This is something I have a lot of problems understanding. I have read up on how to alter the accessibility of variables and functions, but it's never really stuck. I just don't get why I need to do it. Maybe its just another level of complexity that my mind can't handle while learning the fundamentals of programming.
Could someone please explain a bit about two things... 1: why encapsulate? and 2: how to encapsulate? and what requirements are for different access types?
Michael
travel2light - 12 Mar 2008 16:04 GMT On 12 Mar, 01:02, Roedy Green <see_webs...@mindprod.com.invalid> wrote:
> On Mon, 10 Mar 2008 16:52:16 -0700 (PDT), travel2light > <everything2li...@yahoo.co.uk> wrote, quoted or indirectly quoted [quoted text clipped - 15 lines] > Roedy Green Canadian Mind Products > The Java Glossaryhttp://mindprod.com I'm not in your world. I've never been around programmers and I've never accociated with them. I am 100% self taught and therefore I've never been been inclined, or had reason to think about your question. I've also never had reason or inclination to consider if/why professional programmers use comments.
Your comment also assumes that anyone learning java is young. This is quite a big assumption.
Michael
Lew - 13 Mar 2008 00:52 GMT > Your comment also assumes that anyone learning java is young. This is > quite a big assumption. "Younger programmers" does not refer to chronological age, but to when one was "born" into programming. See Paul Erdos's use of being "born" for a similar specialization.
 Signature Lew
travel2light - 13 Mar 2008 01:54 GMT > > Your comment also assumes that anyone learning java is young. This is > > quite a big assumption. [quoted text clipped - 5 lines] > -- > Lew No problem.
Roedy Green - 10 Mar 2008 23:05 GMT On Mon, 10 Mar 2008 08:02:36 -0700 (PDT), travel2light <everything2light@yahoo.co.uk> wrote, quoted or indirectly quoted someone who said :
>Okay here it is! Your big problem is commenting. You get full brownie points for your excellent initial comment that describes what the program is for. Even pros often fail to provide one that good..
I find when doing a GUI that a diagram of roughly that the screen looks like really helps understand the code. There is SO much busywork in a Java GUI it is easy to get lost in detail.
You also want at the bare minimum a comment on each GUI component what it is for, what typical values it has.
Your comment about placement of the *.java file oddly should NOT be there. Your program is perfectly standard. Putting in such a comment makes it look as if there is something weird about it.
For practice, put a JavaDoc comment on every variable and method declaration, and use a tool like IntelliJ Idea to make sure they are complete. Don't write Pythonesque Javadocs like Sun sometimes does e.g. /** set the Skurtlewax property true or false * @param n value to set the property to */ void setSkurtlewax ( boolean n )
Any Java novice could deduce that. What you want to know is what the heck is a skurtlewax property? What does it MEAN when you set it true.
You also might like to read my essay on variable naming. You tend to use non-descriptive names, or names that tell you information that is already apparent from the code.
see http://mindprod.com/jgloss/naming.html --
Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
travel2light - 11 Mar 2008 01:07 GMT On 10 Mar, 22:05, Roedy Green <see_webs...@mindprod.com.invalid> wrote:
> On Mon, 10 Mar 2008 08:02:36 -0700 (PDT), travel2light > <everything2li...@yahoo.co.uk> wrote, quoted or indirectly quoted [quoted text clipped - 5 lines] > excellent initial comment that describes what the program is for. > Even pros often fail to provide one that good.. Thanks
> I find when doing a GUI that a diagram of roughly that the screen > looks like really helps understand the code. There is SO much > busywork in a Java GUI it is easy to get lost in detail. Well at the moment I have been keeping my GUI's really simple. Honestly JPanels and JLayouts give me a headache, this is why I tend to use the JBuilder graphical features to create these. But I also know it's limitations. I will try your idea about using diagrams. But I tend to be very impulsive I just want to get down to the nitty gritty.
> You also want at the bare minimum a comment on each GUI component what > it is for, what typical values it has. Okay
> Your comment about placement of the *.java file oddly should NOT be > there. Your program is perfectly standard. Putting in such a comment [quoted text clipped - 11 lines] > Any Java novice could deduce that. What you want to know is what the > heck is a skurtlewax property? What does it MEAN when you set it true. Thank you for the suggestion. I will look into it. Is there a reason for using JavaDoc comments instead of normal comments? I see JavaDoc all the time in the documentation, but I've never understood the advantage of creating my own.
> You also might like to read my essay on variable naming. You tend to > use non-descriptive names, or names that tell you information that is > already apparent from the code. > > seehttp://mindprod.com/jgloss/naming.html > -- I have to admit I do find it really difficult to think of good variable names.
> Roedy Green Canadian Mind Products > The Java Glossaryhttp://mindprod.com Thank you so much for all your advice.
Michael
Lew - 11 Mar 2008 02:27 GMT > Is there a reason > for using JavaDoc comments instead of normal comments? I see JavaDoc > all the time in the documentation, but I've never understood the > advantage of creating my own. Remember when you said,
>> I already discovered the importance of comments the hard way! I've >> been revisiting some projects I started a long time ago and I've been >> having a terrible time trying to make sense of them. ?
When you design a class to be used, that is, when you design a class as an API, you take on responsibilities to the programmers and classes that use your API. These responsibilities imbue an attitude of anal-retentive commenting, documenting and testing of one's API before subjecting it to the abuse its users shall surely heap upon it.
One way to facilitate a happy experience for API consumers is to provide documentation of the API, external to the source code - a distillation of the API's public and protected members and methods, what they're for and how to use them. It would be especially nice if such API documentation were as thoroughly organized and interlinked as Sun's own API docs, <http://java.sun.com/javase/6/docs/api/>
It would be almost magically delicious if generation of such documents could be automated through some tool that would, let's say, scan your source for specially formatted comments on classes and their protected or public members, then emit such beautiful, browsable pages in nice HTML, with fine control over package-level comments, headers, footers and all that rot. You'd have it lift all comments that began with, say, /** (slash, asterisk, asterisk), so it would work as a normal comment but be special to your documentation tool.
Now your source becomes "literate programming" - compilable, self-documenting artifacts. You get the visible part of the comments independently of the source via the special Java documentation.
Let's call this special Java documentation magic tool "javadoc", and its special magic comment format "javadoc comments". <http://java.sun.com/javase/6/docs/technotes/tools/solaris/javadoc.html> <http://java.sun.com/javase/6/docs/technotes/tools/windows/javadoc.html>
 Signature Lew
travel2light - 11 Mar 2008 04:23 GMT > Now your source becomes "literate programming" - compilable, self-documenting > artifacts. You get the visible part of the comments independently of the [quoted text clipped - 7 lines] > -- > Lew But if I do this other people will be able to understand my code better, right? Hmmm I think this will feel like too much of a step in the *wrong* direction. ;-) http://mindprod.com/jgloss/unmain.html
Roedy Green - 11 Mar 2008 05:17 GMT On Mon, 10 Mar 2008 17:07:55 -0700 (PDT), travel2light <everything2light@yahoo.co.uk> wrote, quoted or indirectly quoted someone who said :
>I tend to be very impulsive I just want to get down to the nitty >gritty. That is the way nearly all new programmers are. They don't realise that in the long run the docs are MORE important. Anyone can write code. Any skilled programmer can figure out what code IS doing now. Not anyone can understand what the app is TRYING to do. That's where you need help. This is especially true in non-working newbie code.
Doing docs first tends to make you write cleaner code. If you can't simply describe what a method does, it does deserve to exist.
You spend far more time over the years maintaining code that writing it. Writing it is easy. Maintaining is hard unless you have PREPLANNED to make the obviously changes easy.
The discipline is. Every time you have to maintain and you have a difficultly, redesign, add docs, etc, to make doing ANTOTHER similar mod something you can do is your sleep. If you don't it will get harder and harder and you will introduce more and more bugs every time you make a tiny change.
The basic principle is encapsulation. Tell the computer program each fact in only one place. If you need to tell it more than once, put in a cross referencing comment to remind yourself to modify code in the other place to match.
--
Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Arved Sandstrom - 11 Mar 2008 18:44 GMT > On 10 Mar, 22:05, Roedy Green <see_webs...@mindprod.com.invalid> > wrote: [ SNIP ]
>> I find when doing a GUI that a diagram of roughly that the screen >> looks like really helps understand the code. There is SO much [quoted text clipped - 6 lines] > I tend to be very impulsive I just want to get down to the nitty > gritty. [ SNIP ]
Impulse understood - every programmer gets it and sometimes/often succumbs to said impulse. However, 100% of the time you will get better code if you design first.
For a GUI (whether a Swing app or a Web interface) part of the design involves mockups of the screens that users will see and use. You can use a prototype program that produces the GUI windows/Web pages, that has very little business functionality otherwise, or you can use hand-drawn pictures on paper, etc. The intent is to take the requirements for the application (this is what the program will do) and translate that into use cases (scenarios, stories) that describe in high-level language how the user (person, other system, a device) will do a specific thing. Your prototype application screens or drawn/printed GUI pictures should then support each of the tasks that has been identified. It's only once you've done design like this that you should code out your complete logic.
In connection with the above, it's actually during the requirements/design phase that you start creating tests. Since that subject came up earlier in this thread.
AHS
Andrew Thompson - 11 Mar 2008 03:22 GMT On Mar 11, 9:05 am, Roedy Green <see_webs...@mindprod.com.invalid> wrote: ...
> ...Don't write Pythonesque Javadocs like Sun sometimes does > e.g. > /** set the Skurtlewax property true or false > * @param n value to set the property to > */ > void setSkurtlewax ( boolean n ) Would it not make more sense to describe what skurtlewax is at the declaration?
/** Whether the buyer wants the waxing technique used for rust protection. */ boolean skurtlewax;
I have never understood the benefit of putting JavaDoc comments to set and get methods - they either should be so stupidly simple that comments are redundant, or renamed to something else to reflect what they *really* do.
-- Andrew T. PhySci.org
Roedy Green - 11 Mar 2008 05:20 GMT On Mon, 10 Mar 2008 19:22:13 -0700 (PDT), Andrew Thompson <andrewthommo@gmail.com> wrote, quoted or indirectly quoted someone who said :
>Would it not make more sense to describe what >skurtlewax is at the declaration? > > /** Whether the buyer wants the waxing > technique used for rust protection. */ > boolean skurtlewax; If the boolean is private and the accessors public, the usual case, you have to put the skurtlewax description on the getters/setters. This is irritatingly redundant. I lobby for Delphi like properties. You would put the docs on the property.
You further have the problem of deciding to document the method or the boolean parm / return --
Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Andrew Thompson - 11 Mar 2008 05:27 GMT On Mar 11, 3:20 pm, Roedy Green <see_webs...@mindprod.com.invalid> wrote:
> On Mon, 10 Mar 2008 19:22:13 -0700 (PDT), Andrew Thompson > <andrewtho...@gmail.com> wrote, quoted or indirectly quoted someone [quoted text clipped - 9 lines] > If the boolean is private and the accessors public, the usual case, > you have to put the skurtlewax description on the getters/setters. You don't *have* to, the javadoc tool can be configured to show all levels of access - though that is a kludgy approach to ensuring the JavaDoc comment of a private attribute is visible. It also risks swamping the reader with irrelevant comments on/listings of other private attributes.
..OK - I am beginning to see your point.
-- Andrew T. PhySci.org
David Roden - 10 Mar 2008 12:04 GMT > I've written an application that pretty much summarises what I have > learnt so far. It is a single compilable source file. It it is a single source file then either
a) it's very long: you have not learned to organize your classes and source files, or b) it's very short: you have by far not yet learned enough to consider java programming as a career, or c) it's medium-sized: worst of the two above. :)
David
travel2light - 13 Mar 2008 01:45 GMT > Hi, > I need someone with professional java development experience to [quoted text clipped - 15 lines] > > Michael I just want to thank everyone who replied and helped me understand the problems with my code. I really appreciated all of time and wisdom.
Michael
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|