Commit 8f9b4d02 authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Some javadoc

parent f33a3506
......@@ -36,18 +36,21 @@ import java.util.*;
*/
public class ActionEditor extends JFrame implements ActionListener{
//The actions in the chain, respectively the Panels representing them
/** The actions in the chain, respectively the Panels representing them */
java.util.List<ActionPanel> aPanels = new LinkedList<ActionPanel>();
/** The icon for the add button */
public ImageIcon add_icon = createIcon("icons/add.png");
/** The icon for the delete button */
public ImageIcon delete_icon = createIcon("icons/delete.png");
//The panel that handels the scrolling through the list of actions
/** The panel that handels the scrolling through the list of actions */
JScrollPane sPane;
//The panel containing the actual ActionPanels
/** The panel containing the actual ActionPanels */
JPanel actions_p = new JPanel();
//Opens a PopupMenu from which the user can add an action to the end of the chain
JButton add_btn = new JButton(add_icon);
/** Opens a PopupMenu from which the user can add an action to the end of the chain */
JButton add_btn = new JButton(add_icon);
/** The OK button */
JButton ok_btn = new JButton(Language.get("BUTTON_OK"));
JPopupMenu actions_pu = new JPopupMenu(Language.get("ACTIONS_PU"));
......@@ -109,7 +112,10 @@ public class ActionEditor extends JFrame implements ActionListener{
//The skin item to which the represented action chain belongs
Item parent;
/** Creates a new instance of ActionEditor */
/**
* Creates a new instance of ActionEditor
* @param p The item whose action will be edited with this editor
*/
public ActionEditor(Item p) {
super(Language.get("WIN_ACTIONS_TITLE"));
......@@ -356,6 +362,7 @@ public class ActionEditor extends JFrame implements ActionListener{
}
/**
* Reacts to user interaction
* @param e The action event
*/
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(add_btn)) actions_pu.show(add_btn,0,0);
......@@ -379,6 +386,8 @@ public class ActionEditor extends JFrame implements ActionListener{
}
/**
* Creates an ImageIcon out of a file
* @param filename The name of the image file
* @return <i>null</i> if an Exception occured, otherwise an ImageIcon representing the given image file.
*/
public ImageIcon createIcon(String filename) {
java.awt.Image img = null;
......@@ -391,38 +400,4 @@ public class ActionEditor extends JFrame implements ActionListener{
return null;
}
}
/**
* For testing purposes
*/
public static void main (String[] args) {
Config.load();
Language.loadLanguageByCode("en");
try {
String laf = Config.get("swing.laf");
String lafClass = laf;
if(laf!=null) {
if(laf.equals("System")) {
lafClass = UIManager.getSystemLookAndFeelClassName();
}
if(laf.equals("Metal: Steel")) {
lafClass = UIManager.getCrossPlatformLookAndFeelClassName();
javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
} else if(laf.equals("Metal: Ocean")) {
lafClass = UIManager.getCrossPlatformLookAndFeelClassName();
javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.OceanTheme());
}
}
UIManager.setLookAndFeel(lafClass);
}
catch (Exception ex) {
ex.printStackTrace();
}
JFrame.setDefaultLookAndFeelDecorated(true);
ActionEditor ae = new ActionEditor(null);
ae.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ae.editAction("none;dialogs.changeSkin();dialogs.fileSimple();dialogs.file();dialogs.directory();dialogs.disc();dialogs.net();dialogs.messages();dialogs.prefs();dialogs.fileInfo();dialogs.playlist();dialogs.streamingWizard();dialogs.popup();dialogs.audioPopup();dialogs.videoPopup();dialogs.miscPopup();equalizer.enable();equalizer.disable();vlc.play();vlc.pause();vlc.stop();vlc.faster();vlc.slower();vlc.mute();" +
"vlc.volumeUp();vlc.volumeDown();vlc.fullscreen();vlc.snapshot();vlc.onTop();vlc.minimize();vlc.quit();playlist.add();playlist.del();playlist.next();playlist.previous();playlist.sort();playlist.setRandom(true);playlist.setLoop(true);playlist.setRepeat(true);playlist.load();playlist.save();dvd.nextTitle();dvd.previousTitle();dvd.nextChapter();dvd.previousChapter();dvd.rootMenu();WindowID.show();WindowID.hide();" +
"WindowID.maximize();WindowID.unmaximize();WindowID.setLayout(LayoutID)");
}
}
......@@ -40,7 +40,11 @@ public class ActionPanel extends JPanel {
JTextField windowid_tf, layoutid_tf;
JComboBox bool_cb;
/** Creates a new instance of ActionPanel */
/**
* Creates a new action panel
* @param act The action string
* @param ae_ The action editor containing this action panel
*/
public ActionPanel(String act,ActionEditor ae_) {
action=act;
ae=ae_;
......
......@@ -33,19 +33,21 @@ import java.util.*;
* @author Daniel Dreibrodt
*/
public class Bezier {
/** The maximal number of points in a bezier curve */
public final int MAX_BEZIER_POINT = 1023;
/**
* Values to indicate which coordinate(s) must be checked to consider
* that two points are distinct
*/
/** Constant value indicating that both coordinates have to be checked in order to distinguish two points */
public static final int kCoordsBoth = 0;
/** Constant value indicating that only the x coordinate has to be checked in order to distinguish two points */
public static final int kCoordsX = 1;
/** Constant value indicating that only the y coordinate has to be checked in order to distinguish two points */
public static final int kCoordsY = 2;
/** number of control points */
int m_nbCtrlPt;
/** lists containing the coordinates of the control points */
/** list containing the x coordinates of the control points */
List<Float> m_ptx = new LinkedList<Float>();
/** list containing the y coordinates of the control points */
List<Float> m_pty = new LinkedList<Float>();
/** Vector containing precalculated factoriels */
List<Float> m_ft = new LinkedList<Float>();
......@@ -58,7 +60,12 @@ public class Bezier {
/** Vector with the percentages associated with the points of the curve */
List<Float> m_percVect = new LinkedList<Float>();
/** Creates a new instance of Bezier */
/**
* Creates a new instance of Bezier
* @param x_ The x coordinates of the bezier curve points
* @param y_ The y coordinates of the bezier curve points
* @param flag Indicates whether x, y or both coordinates of a point have to be considered when distinguishing them
*/
public Bezier(int[] x_,int[] y_, int flag) {
// Copy the control points coordinates
for (int i=0;i<x_.length;i++) {
......@@ -113,20 +120,33 @@ public class Bezier {
m_percVect.set(m_nbPoints - 1, 1f);
}
/** Get the number of control points used to define the curve */
/**
* Get the number of control points used to define the curve
* @return The number of control points
*/
public final int getNbCtrlPoints() {
return m_nbCtrlPt;
}
/** Return the percentage (between 0 and 1) of the curve point nearest from (x, y) */
/**
* Return the percentage of the curve point nearest to a given point
* @param x The x coordinate of the point to be checked
* @param y The y coordinate of the point to be checked
* @return The percentage value [0-1] on the curve corresponding most closely to the given point
*/
public final float getNearestPercent( int x, int y ) {
int nearest = findNearestPoint( x, y );
return m_percVect.get(nearest);
}
/**
* Return the distance of (x, y) to the curve, corrected
* Return the distance of a point to the curve, corrected
* by the (optional) given scale factors
* @param x The x coordinate of the point
* @param y The y coordinate of the point
* @param xScale The x scale factor
* @param yScale The y scale factor
* @return The distance from the point to the curve multiplied by the scale factors
*/
public final float getMinDist( int x, int y, float xScale , float yScale ) {
int nearest = findNearestPoint( x, y );
......@@ -137,7 +157,9 @@ public class Bezier {
/**
* Get the coordinates of the point at t percent of
* the curve (t must be between 0 and 1)
* the curve (t must be between 0 and 1)
* @param t The percentage value
* @return The point at percentage t of the curve
*/
public final Point2D.Float getPoint( float t ) {
// Find the precalculated point whose percentage is nearest from t
......@@ -159,7 +181,10 @@ public class Bezier {
return new Point2D.Float (m_leftVect.get(refPoint - 1), m_topVect.get(refPoint - 1));
}
/** Get the width (maximum abscissa) of the curve */
/**
* Get the width (maximum abscissa) of the curve
* @return The curve's width
*/
public final int getWidth() {
int width = 0;
for( int i = 0; i < m_nbPoints; i++ )
......@@ -172,7 +197,10 @@ public class Bezier {
return width;
}
/** Get the height (maximum ordinate) of the curve */
/**
* Get the height (maximum ordinate) of the curve
* @return The curve's height
*/
public final int getHeight() {
int height = 0;
for( int i = 0; i < m_nbPoints; i++ )
......@@ -185,7 +213,12 @@ public class Bezier {
return height;
}
/** Return the index of the curve point that is the nearest from (x, y) */
/**
* Finds the nearest reference point of the curve to a given point
* @param x The x coordinate of the point
* @param y The y coordinate of the point
* @return the index of the curve point that is the nearest to the given point
*/
private int findNearestPoint( int x, int y ) {
// The distance to the first point is taken as the reference
int refPoint = 0;
......@@ -210,6 +243,8 @@ public class Bezier {
/**
* Compute the coordinates of a point corresponding to a given
* percentage
* @param t The percentage
* @return The corresponding point
*/
private Point2D.Float computePoint( float t ) {
// See http://astronomy.swin.edu.au/~pbourke/curves/bezier/ for a simple
......@@ -227,13 +262,20 @@ public class Bezier {
return new Point2D.Float(xPos,yPos);
}
/** Helper function to compute a coefficient of the curve */
/**
* Helper function to compute a coefficient of the curve
*/
private float computeCoeff( int i, int n, float t ) {
return (power( t, i ) * power( 1 - t, (n - i) ) *
(m_ft.get(n) / m_ft.get(i) / m_ft.get(n - i)));
}
/** x^n */
/**
* x^n
* @param x The basis
* @param n The exponent
* @see java.lang.Math.pow()
*/
private float power( float x, int n ) {
return (float)Math.pow( x, n );
}
......
......@@ -41,6 +41,7 @@ public class BooleanExpressionEvaluator {
}
/**
* Converts an infix boolean expression to reverse polish notation
* @param rExpr The boolean expression
*/
public void parse(String rExpr) {
m_stack.clear();
......
......@@ -37,12 +37,13 @@ public class CustomFileFilter extends FileFilter{
String desc;
String[] ext;
/** Creates a new instance of CustomFileFilter
* @param fc_ The file chooser that uses this file filter
* @param ext_ An array of Strings representing the accepted extensions. e.g { "bmp", "jpg", "jpeg"}
* @param desc_ The description of the FileFilter that is displayed in the FileChooser
* @param oir_ If true files can be only chosen inside the given root folder
* @param r_ The root folder (only useful in connection with <pre>oir_</pre>)
/**
* Creates a new custom FileFilter
* @param fc_ The file chooser that uses this file filter
* @param ext_ An array of Strings representing the accepted extensions. e.g { "bmp", "jpg", "jpeg"}
* @param desc_ The description of the FileFilter that is displayed in the FileChooser
* @param oir_ If true files can be only chosen inside the given root folder
* @param r_ The root folder (only useful in connection with <pre>oir_</pre>)
**/
public CustomFileFilter(JFileChooser fc_, String[] ext_, String desc_, boolean oir_, String r_) {
fc=fc_;
......@@ -51,6 +52,14 @@ public class CustomFileFilter extends FileFilter{
onlyinroot=oir_;
root = r_;
}
/**
* Creates a new custom FileFilter
* @param fc_ The file chooser that uses this file filter
* @param ext_ The accepted file extension
* @param desc_ The description of the FileFilter that is displayed in the FileChooser
* @param oir_ If true files can be only chosen inside the given root folder
* @param r_ The root folder (only useful in connection with <pre>oir_</pre>)
*/
public CustomFileFilter(JFileChooser fc_, String ext_, String desc_, boolean oir_, String r_) {
fc=fc_;
String[] extt = new String[1];
......@@ -60,7 +69,11 @@ public class CustomFileFilter extends FileFilter{
onlyinroot=oir_;
root = r_;
}
/** Checks whether a file is acceptable or not **/
/**
* Checks whether a file is acceptable or not
* @param f The file to be checked
* @return Whether the file should be shown in the file list or not
*/
public boolean accept(File f) {
if(!f.getPath().startsWith(root) && onlyinroot) {
fc.setCurrentDirectory(new File(root));
......@@ -77,7 +90,8 @@ public class CustomFileFilter extends FileFilter{
return false;
}
/**
* Returns a description for this FileFilter
* Returns a description for this FileFilter
* @return The FileFilter's description
*/
public String getDescription() {
return desc;
......@@ -88,13 +102,13 @@ public class CustomFileFilter extends FileFilter{
* @return Extension of <pre>f</pre>
*/
public String getExtension(File f) {
String ext = null;
String x = null;
String s = f.getName();
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i+1).toLowerCase();
x = s.substring(i+1).toLowerCase();
}
return ext;
return x;
}
}
\ No newline at end of file
......@@ -60,6 +60,9 @@ public class FrameUpdater extends Thread{
return;
}
/**
* Stops the FrameUpdater
*/
public void stopRunning() {
run = false;
}
......
......@@ -39,12 +39,15 @@ public class GlobalVariables implements ActionListener{
public String $V = "50";
/** Current time **/
public String $T = "0:55:55";
/** Current time without hours if zero */
public String $t = "55:55";
/** Remaining time **/
public String $L = "0:44:44";
/** Remaining time without hours if zero */
public String $l = "44:44";
/** Duration **/
public String $D = "0:99:99";
/** Duration without hours if zero */
public String $d = "99:99";
/** Value of the help attribute **/
public String $H = "Help text";
......
......@@ -19,7 +19,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package vlcskineditor;
import java.awt.Graphics2D;
......@@ -30,58 +29,84 @@ import javax.swing.tree.DefaultMutableTreeNode;
* @author Daniel Dreibrodt
*/
public abstract class Item {
/** Represents the skin to which an item belongs */
public Skin s;
/* Common attributes */
public Skin s;
/*
* Common attributes
* See the skins2 documentation
*/
/** Default ID value */
public final String ID_DEFAULT = "Unnamed";
/** Default visible value */
public final String VISIBLE_DEFAULT = "true";
/** Default X value */
public final int X_DEFAULT = 0;
/** Default Y value */
public final int Y_DEFAULT = 0;
/** Default lefttop value */
public final String LEFTTOP_DEFAULT = "lefttop";
/** Default rightbottom value */
public final String RIGHTBOTTOM_DEFAULT = "lefttop";
/** Default xkeepratio value */
public final boolean XKEEPRATIO_DEFAULT = false;
/** Default ykeepratio value */
public final boolean YKEEPRATIO_DEFAULT = false;
/** Default help value */
public final String HELP_DEFAULT = "";
/** The Item's ID attribute */
public String id = ID_DEFAULT;
/** The Item's visible attribute */
public String visible = VISIBLE_DEFAULT;
/** The Item's x attribute */
public int x = X_DEFAULT;
/** The Item's y attribute */
public int y = Y_DEFAULT;
/** The lefttop attribute */
public String lefttop = LEFTTOP_DEFAULT;
/** The Item's rightbottom attribute */
public String rightbottom = RIGHTBOTTOM_DEFAULT;
/** The Item's xkeepratio attribute */
public boolean xkeepratio = XKEEPRATIO_DEFAULT;
/** The Item's ykeepratio attribute */
public boolean ykeepratio = YKEEPRATIO_DEFAULT;
/** The Item's help attrtibute */
public String help = HELP_DEFAULT;
/** The Item's type */
public String type = "undefined";
public boolean selected = false;
public boolean hovered = false;
public boolean clicked = false;
/** Indicates whether this Item is selected in the item list */
protected boolean selected = false;
/** Indicates whether this Item is hovered by the mouse in the preview window */
protected boolean hovered = false;
/** Indicates whether this Item is clicked on in the preview window */
protected boolean clicked = false;
/** The absolute x coordinates of the parent which contains this Item */
public int offsetx = 0;
/** The absolute y coordinates of the parent which contains this Item */
public int offsety = 0;
/** Store for the parsed visible attribute, indicating whether the Item is drawn or not */
protected boolean vis = true;
/** Determines whether the process of creating the object has finished **/
public boolean created = false;
/** Creates a new instance of Item */
public Item() {
}
/** Show a dialog to modify the items's parameters */
public abstract void showOptions();
public abstract void showOptions();
/** Update the Item's attributes according to the user input */
public abstract void update();
/** Creates the XML code representing the item */
/** Creates the XML code representing the item
* @param indent The indentation string
* @return The indented XML code
*/
public abstract String returnCode(String indent);
/** Draws the item to a graphics context
* @param g graphics context
* @param z zoom factor
*/
public abstract void draw(Graphics2D g, int z);
/** Draws the item to a graphics context with the offset x,y
* @param g Graphics context
* @param x X offset
......@@ -89,69 +114,125 @@ public abstract class Item {
* @param z Zoom factor
*/
public abstract void draw(Graphics2D g, int x, int y, int z);
/** Creates a DefaultMutableTreeNode to be displayed in the items tree */
public abstract DefaultMutableTreeNode getTreeNode();
/** If the given id is that of this item or one of the item's contained items the fitting item will be returned, else null **/
/** Creates a DefaultMutableTreeNode to be displayed in the items tree
* @return The DefaultMutableTreeNode representation of this Item
*/
public abstract DefaultMutableTreeNode getTreeNode();
/**
* Gets an Item of the given ID
* @param id_ The ID of the desired Item
* @return If this Item or one of its children contains an Item with the given ID it is returned, otherwise null is returned
*/
public Item getItem(String id_) {
if(id.equals(id_)) return this;
else return null;
if (id.equals(id_)) {
return this;
} else {
return null;
}
}
/** If an item contains a subitem of the given id the list containing the subitem is returned **/
/**
* Gets the list containing the Item with the given ID
* @param id_ ID of the item whose parent list is looked for
* @return If this Item or one of its children contains an Item with the given ID its parent list is returned, otherwise null is returned
*/
public java.util.List<Item> getParentListOf(String id_) {
return null;
}
/** If an item contains a subitem of the given id the itemis returned **/
/**
* Gets the parent Item of the Item with the given ID
* @param id_ ID of the item whose parent is looked for
* @return If this Item or one of its children contains an Item with the given ID its parent item is returned, otherwise null is returned
*/
public Item getParentOf(String id_) {
return null;
}
/** Sets whether the item is selected in the tree or not **/
/**
* Sets whether the Item is selected in the tree or not
* @param s Selected or not
*/
public void setSelected(boolean s) {
selected = s;
}
/** Sets whether the item is hovered by the mouse in the tree or not **/
/**
* Sets whether the Item is hovered by the mouse in the preview or not
* @param h Hovered or not
*/
public void setHover(boolean h) {
hovered = h;
}
/** Sets whether the item is clicked in the tree or not **/
/**
* Sets whether the Item is clicked in the preview or not
* @param c Clicked or not
*/
public void setClicked(boolean c) {
clicked = c;
}
/** Checks whether the given coordinate is inside the item **/
/**
* Checks whether the given point is inside the Item
* @param x_ The point's x coordinate
* @param y_ The point's y coordinate
* @return True when the point is contained in the Item, false otherwise
*/
public boolean contains(int x_, int y_) {
return (x==x_ && y==y_);
return (x == x_ && y == y_);
}
/** Set offset **/
/**
* Sets the absolut offset of the Item's parent
* @param x_ The parents absolute x location
* @param y_ The parents absolute y location
*/
public void setOffset(int x_, int y_) {
offsetx=x_;
offsety=y_;
offsetx = x_;
offsety = y_;
}
/** Tells the item that an action attribute has been changed by the ActionEditor <code>ae</code>**/
/**
* Tells the Item that an action attribute has been changed by the ActionEditor <code>ae</code>
* @param ae The ActionEditor who changed the action attribute
*/
public void actionWasEdited(ActionEditor ae) {
}
}
/**
* Checks whether the resource with the given ID is used by this item or one of its subitems
* Checks whether the resource with the given ID is used by this Item or one of its subitems
* @param id_ The resource's id
* @return True if used, false otherwise
*/
public boolean uses(String id_) {
return false;
}
/** Renames the item after the copy process **/
public void renameForCopy(String p) {
p = p.replaceAll("%oldid%", id);
String newid_base = p;
/**
* Renames the Item after the copy process
* @param p The rename pattern, where %oldid% will be replaced by the Item's old ID
*/
public void renameForCopy(String p) {
p = p.replaceAll("%oldid%", id);
String newid_base = p;
String newid = newid_base;
int i = 1;
while(s.idExists(newid)) {
while (s.idExists(newid)) {
i++;
newid = newid_base+"_"+String.valueOf(i);
newid = newid_base + "_" + String.valueOf(i);
}
id = newid;
}
/**
* Invokes the item to update its variables that depend on the global variables
* Invokes the item to update its variables that depend on the global variables,
* that is e.g. visibility
*/
public void updateToGlobalVariables() {
vis = s.gvars.parseBoolean(visible);
}
}
}
......@@ -42,6 +42,10 @@ public class ItemTransferHandler extends TransferHandler {
private Skin s;
private DataFlavor itemFlavor = new DataFlavor(Item.class, "Skin item");
/**
* Creates a new ItemTransferHandler for the given skin
* @param s The skin
*/
public ItemTransferHandler(Skin s) {
this.s = s;
}
......
......@@ -19,7 +19,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package vlcskineditor;
import java.io.*;
......@@ -32,22 +31,22 @@ import java.util.List;
* @author Daniel Dreibrodt
*/
public class Language {
private static Hashtable<String, String> strings = new Hashtable<String, String>();
private static Hashtable<String, String> strings = new Hashtable<String, String>();
private static LinkedList<Language> langs = new LinkedList<Language>();
static {
try {
File index = new File("lang/languages.txt");
FileReader fr = new FileReader(index);
BufferedReader br = new BufferedReader(fr);
String line = "";
while( (line = br.readLine()) != null) {
line = new String(line.getBytes(),"UTF-8");
while((line = br.readLine()) != null) {
line = new String(line.getBytes(), "UTF-8");
if(!line.startsWith("#")) {
String[] fields = line.split("\\|");
if(fields.length==3) {
if(fields.length == 3) {
langs.add(new Language(fields[0], fields[1], fields[2]));
}
}
......@@ -59,7 +58,7 @@ public class Language {
}
}
private String name, code;
private String name, code;
private File file;
/**
......@@ -71,26 +70,38 @@ public class Language {
private Language(String code, String name, String file) {
this.name = name;
this.code = code;
this.file = new File("lang",file);
this.file = new File("lang", file);
}
/**
* Gets the languages ISO code
* @return The ISO language code
*/
public String getCode() {
return code;
}
/**
* Gets the language's name
* @return The native name of the language
*/
public String getName() {
return name;
}
/**
* Gets the language file
* @return The language file
*/
public File getFile() {
return file;
}
@Override
public String toString() {
return name+" ("+code+")";
return name + " (" + code + ")";
}
/**
* Loads the current language from a file
* @param f The language file, e.g. lang/English.txt
......@@ -99,24 +110,23 @@ public class Language {
try {
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
String line = "";
while( (line = br.readLine()) != null) {
line = new String(line.getBytes(),"UTF-8");
while((line = br.readLine()) != null) {