code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
/*
* Configuration.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ini;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.util.Enumeration;
import java.util.Hashtable;
import javazoom.jlgui.player.amp.util.Config;
/**
* A Configuration is used to save a set of configuration
* properties. The properties can be written out to disk
* in "name=value" form, and read back in.
*
* @author Jeremy Cloud
* @version 1.2.0
*/
public class Configuration
{
private File config_file = null;
private URL config_url = null;
private Hashtable props = new Hashtable(64);
/**
* Constructs a new Configuration object that stores
* it's properties in the file with the given name.
*/
public Configuration(String file_name)
{
// E.B - URL support
if (Config.startWithProtocol(file_name))
{
try
{
this.config_url = new URL(file_name);
}
catch (Exception e)
{
e.printStackTrace();
}
load();
}
else
{
this.config_file = new File(file_name);
load();
}
}
/**
* Constructs a new Configuration object that stores
* it's properties in the given file.
*/
public Configuration(File config_file)
{
this.config_file = config_file;
load();
}
/**
* Constructs a new Configuration object that stores
* it's properties in the given file.
*/
public Configuration(URL config_file)
{
this.config_url = config_file;
load();
}
/**
* Constructs a new Configuration object that doesn't
* have a file associated with it.
*/
public Configuration()
{
this.config_file = null;
}
/**
* @return The config file.
*/
public File getConfigFile()
{
return config_file;
}
/**
* Adds a the property with the given name and value.
*
* @param name The name of the property.
* @param value The value of the property.
*/
public void add(String name, String value)
{
props.put(name, value);
}
/**
* Adds the boolean property.
*
* @param name The name of the property.
* @param value The value of the property.
*/
public void add(String name, boolean value)
{
props.put(name, value ? "true" : "false");
}
/**
* Adds the integer property.
*
* @param name The name of the property.
* @param value The value of the property.
*/
public void add(String name, int value)
{
props.put(name, Integer.toString(value));
}
/**
* Adds the double property.
*
* @param name The name of the property.
* @param value The value of the property.
*/
public void add(String name, double value)
{
props.put(name, Double.toString(value));
}
/**
* Returns the value of the property with the
* given name. Null is returned if the named
* property is not found.
*
* @param The name of the desired property.
* @return The value of the property.
*/
public String get(String name)
{
return (String) props.get(name);
}
/**
* Returns the value of the property with the
* given name. 'default_value' is returned if the
* named property is not found.
*
* @param The name of the desired property.
* @param default_value The default value of the property which is returned
* if the property does not have a specified value.
* @return The value of the property.
*/
public String get(String name, String default_value)
{
Object value = props.get(name);
return value != null ? (String) value : default_value;
}
/**
* Returns the value of the property with the given name.
* 'false' is returned if the property does not have a
* specified value.
*
* @param name The name of the desired property.
* @param return The value of the property.
*/
public boolean getBoolean(String name)
{
Object value = props.get(name);
return value != null ? value.equals("true") : false;
}
/**
* Returns the value of the property with the given name.
*
* @param name The name of the desired property.
* @param default_value The default value of the property which is returned
* if the property does not have a specified value.
* @param return The value of the property.
*/
public boolean getBoolean(String name, boolean default_value)
{
Object value = props.get(name);
return value != null ? value.equals("true") : default_value;
}
/**
* Returns the value of the property with the given name.
* '0' is returned if the property does not have a
* specified value.
*
* @param name The name of the desired property.
* @param return The value of the property.
*/
public int getInt(String name)
{
try
{
return Integer.parseInt((String) props.get(name));
}
catch (Exception e)
{
}
return -1;
}
/**
* Returns the value of the property with the given name.
*
* @param name The name of the desired property.
* @param default_value The default value of the property which is returned
* if the property does not have a specified value.
* @param return The value of the property.
*/
public int getInt(String name, int default_value)
{
try
{
return Integer.parseInt((String) props.get(name));
}
catch (Exception e)
{
}
return default_value;
}
/**
* Returns the value of the property with the given name.
* '0' is returned if the property does not have a
* specified value.
*
* @param name The name of the desired property.
* @param return The value of the property.
*/
public double getDouble(String name)
{
try
{
return new Double((String) props.get(name)).doubleValue();
}
catch (Exception e)
{
}
return -1d;
}
/**
* Returns the value of the property with the given name.
*
* @param name The name of the desired property.
* @param default_value The default value of the property which is returned
* if the property does not have a specified value.
* @param return The value of the property.
*/
public double getDouble(String name, double default_value)
{
try
{
return new Double((String) props.get(name)).doubleValue();
}
catch (Exception e)
{
}
return default_value;
}
/**
* Removes the property with the given name.
*
* @param name The name of the property to remove.
*/
public void remove(String name)
{
props.remove(name);
}
/**
* Removes all the properties.
*/
public void removeAll()
{
props.clear();
}
/**
* Loads the property list from the configuration file.
*
* @return True if the file was loaded successfully, false if
* the file does not exists or an error occurred reading
* the file.
*/
public boolean load()
{
if ((config_file == null) && (config_url == null)) return false;
// Loads from URL.
if (config_url != null)
{
try
{
return load(new BufferedReader(new InputStreamReader(config_url.openStream())));
}
catch (IOException e)
{
e.printStackTrace();
return false;
}
}
// Loads from file.
else
{
if (!config_file.exists()) return false;
try
{
return load(new BufferedReader(new FileReader(config_file)));
}
catch (IOException e)
{
e.printStackTrace();
return false;
}
}
}
public boolean load(BufferedReader buffy) throws IOException
{
Hashtable props = this.props;
String line = null;
while ((line = buffy.readLine()) != null)
{
int eq_idx = line.indexOf('=');
if (eq_idx > 0)
{
String name = line.substring(0, eq_idx).trim();
String value = line.substring(eq_idx + 1).trim();
props.put(name, value);
}
}
buffy.close();
return true;
}
/**
* Saves the property list to the config file.
*
* @return True if the save was successful, false othewise.
*/
public boolean save()
{
if (config_url != null) return false;
try
{
PrintWriter out = new PrintWriter(new FileWriter(config_file));
return save(out);
}
catch (IOException e)
{
e.printStackTrace();
return false;
}
}
public boolean save(PrintWriter out) throws IOException
{
Hashtable props = this.props;
Enumeration names = props.keys();
SortedStrings sorter = new SortedStrings();
while (names.hasMoreElements())
{
sorter.add((String) names.nextElement());
}
for (int i = 0; i < sorter.stringCount(); i++)
{
String name = sorter.stringAt(i);
String value = (String) props.get(name);
out.print(name);
out.print("=");
out.println(value);
}
out.close();
return true;
}
public void storeCRC()
{
add("crc", generateCRC());
}
public boolean isValidCRC()
{
String crc = generateCRC();
String stored_crc = (String) props.get("crc");
if (stored_crc == null) return false;
return stored_crc.equals(crc);
}
private String generateCRC()
{
Hashtable props = this.props;
CRC32OutputStream crc = new CRC32OutputStream();
PrintWriter pr = new PrintWriter(crc);
Enumeration names = props.keys();
while (names.hasMoreElements())
{
String name = (String) names.nextElement();
if (!name.equals("crc"))
{
pr.println((String) props.get(name));
}
}
pr.flush();
return "" + crc.getValue();
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ini/Configuration.java | Java | asf20 | 12,484 |
/*
* Alphabetizer.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ini;
/**
* This class alphabetizes strings.
*
* @author Matt "Spiked Bat" Segur
*/
public class Alphabetizer
{
public static boolean lessThan(String str1, String str2)
{
return compare(str1, str2) < 0;
}
public static boolean greaterThan(String str1, String str2)
{
return compare(str1, str2) > 0;
}
public static boolean equalTo(String str1, String str2)
{
return compare(str1, str2) == 0;
}
/**
* Performs a case-insensitive comparison of the two strings.
*/
public static int compare(String s1, String s2)
{
if (s1 == null && s2 == null) return 0;
else if (s1 == null) return -1;
else if (s2 == null) return +1;
int len1 = s1.length();
int len2 = s2.length();
int len = Math.min(len1, len2);
for (int i = 0; i < len; i++)
{
int comparison = compare(s1.charAt(i), s2.charAt(i));
if (comparison != 0) return comparison;
}
if (len1 < len2) return -1;
else if (len1 > len2) return +1;
else return 0;
}
/**
* Performs a case-insensitive comparison of the two characters.
*/
public static int compare(char c1, char c2)
{
if (65 <= c1 && c1 <= 91) c1 += 32;
if (65 <= c2 && c2 <= 91) c2 += 32;
if (c1 < c2) return -1;
else if (c1 > c2) return +1;
else return 0;
}
} | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ini/Alphabetizer.java | Java | asf20 | 2,553 |
/*
* CRC32OutputStream.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ini;
import java.io.OutputStream;
import java.util.zip.CRC32;
/**
* @author Jeremy Cloud
* @version 1.0.0
*/
public class CRC32OutputStream extends OutputStream
{
private CRC32 crc;
public CRC32OutputStream()
{
crc = new CRC32();
}
public void write(int new_byte)
{
crc.update(new_byte);
}
public long getValue()
{
return crc.getValue();
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ini/CRC32OutputStream.java | Java | asf20 | 1,504 |
/*
* SortedStrings.
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ini;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
/**
* An object that represents an array of alpabetized Strings. Implemented
* with an String array that grows as appropriate.
*/
public class SortedStrings extends Alphabetizer implements Cloneable
{
public static final int DEFAULT_SIZE = 32;
private String[] strings;
private int string_count;
private double growth_rate = 2.0;
/**
* Constructor creates a new SortedStrings object of default
* size.
*/
public SortedStrings()
{
clear();
}
/**
* Constructor creates a new SortedStrings object of size passed.
*/
public SortedStrings(int initial_size)
{
clear(initial_size);
}
/**
* Contructor creates a new SortedStrings object using a DataInput
* object. The first int in the DataInput object is assumed to be
* the size wanted for the SortedStrings object.
*/
public SortedStrings(DataInput in) throws IOException
{
int count = string_count = in.readInt();
String[] arr = strings = new String[count];
for (int i = 0; i < count; i++)
arr[i] = in.readUTF();
}
/**
* Contructor creates a new SortedStrings object, initializing it
* with the String[] passed.
*/
public SortedStrings(String[] array)
{
this(array.length);
int new_size = array.length;
for (int i = 0; i < new_size; i++)
add(array[i]);
}
/**
* Clones the SortedStrings object.
*/
public Object clone()
{
try
{
SortedStrings clone = (SortedStrings) super.clone();
clone.strings = (String[]) strings.clone();
return clone;
}
catch (CloneNotSupportedException e)
{
return null;
}
}
/**
* Writes a the SortedStrings object to the DataOutput object.
*/
public void emit(DataOutput out) throws IOException
{
int count = string_count;
String[] arr = strings;
out.writeInt(count);
for (int i = 0; i < count; i++)
out.writeUTF(arr[i]);
}
/**
* Merge two sorted lists of integers. The time complexity of
* the merge is O(n).
*/
public SortedStrings merge(SortedStrings that)
{
int count1 = this.string_count;
int count2 = that.string_count;
String[] ints1 = this.strings;
String[] ints2 = that.strings;
String num1, num2;
int i1 = 0, i2 = 0;
SortedStrings res = new SortedStrings(count1 + count2);
while (i1 < count1 && i2 < count2)
{
num1 = ints1[i1];
num2 = ints2[i2];
if (compare(num1, num2) < 0)
{
res.add(num1);
i1++;
}
else if (compare(num2, num1) < 0)
{
res.add(num2);
i2++;
}
else
{
res.add(num1);
i1++;
i2++;
}
}
if (i1 < count1)
{
for (; i1 < count1; i1++)
res.add(ints1[i1]);
}
else for (; i2 < count2; i2++)
res.add(ints2[i2]);
return res;
}
/**
* Returns a SortedStrings object that has the Strings
* from this object that are not in the one passed.
*/
public SortedStrings diff(SortedStrings that)
{
int count1 = this.string_count;
int count2 = that.string_count;
String[] ints1 = this.strings;
String[] ints2 = that.strings;
String num1, num2;
int i1 = 0, i2 = 0;
SortedStrings res = new SortedStrings(count1);
while (i1 < count1 && i2 < count2)
{
num1 = ints1[i1];
num2 = ints2[i2];
if (compare(num1, num2) < 0)
{
res.add(num1);
i1++;
}
else if (compare(num2, num1) < 0) i2++;
else
{
i1++;
i2++;
}
}
if (i1 < count1)
{
for (; i1 < count1; i1++)
res.add(ints1[i1]);
}
return res;
}
/**
* Clears the Strings from the object and creates a new one
* of the default size.
*/
public void clear()
{
clear(DEFAULT_SIZE);
}
/**
* Clears the Strings from the object and creates a new one
* of the size passed.
*/
public void clear(int initial_size)
{
strings = new String[initial_size];
string_count = 0;
}
/**
* Adds the String passed to the array in its proper place -- sorted.
*/
public void add(String num)
{
if (string_count == 0 || greaterThan(num, strings[string_count - 1]))
{
if (string_count == strings.length) strings = (String[]) Array.grow(strings, growth_rate);
strings[string_count] = num;
string_count++;
}
else insert(search(num), num);
}
/**
* Inserts the String passed to the array at the index passed.
*/
private void insert(int index, String num)
{
if (strings[index] == num) return;
else
{
if (string_count == strings.length) strings = (String[]) Array.grow(strings, growth_rate);
System.arraycopy(strings, index, strings, index + 1, string_count - index);
strings[index] = num;
string_count++;
}
}
/**
* Removes the String passed from the array.
*/
public void remove(String num)
{
int index = search(num);
if (index < string_count && equalTo(strings[index], num)) removeIndex(index);
}
/**
* Removes the String from the beginning of the array to the
* index passed.
*/
public void removeIndex(int index)
{
if (index < string_count)
{
System.arraycopy(strings, index + 1, strings, index, string_count - index - 1);
string_count--;
}
}
/**
* Returns true flag if the String passed is in the array.
*/
public boolean contains(String num)
{
int index = search(num);
return index < string_count && equalTo(strings[search(num)], num);
}
/**
* Returns the number of Strings in the array.
*/
public int stringCount()
{
return string_count;
}
/**
* Returns String index of the int passed.
*/
public int indexOf(String num)
{
int index = search(num);
return index < string_count && equalTo(strings[index], num) ? index : -1;
}
/**
* Returns the String value at the index passed.
*/
public String stringAt(int index)
{
return strings[index];
}
/**
* Returns the index where the String value passed is located
* or where it should be sorted to if it is not present.
*/
protected int search(String num)
{
String[] strings = this.strings;
int lb = 0, ub = string_count, index;
String index_key;
while (true)
{
if (lb >= ub - 1)
{
if (lb < string_count && !greaterThan(num, strings[lb])) return lb;
else return lb + 1;
}
index = (lb + ub) / 2;
index_key = strings[index];
if (greaterThan(num, index_key)) lb = index + 1;
else if (lessThan(num, index_key)) ub = index;
else return index;
}
}
/**
* Returns an String[] that contains the value in the SortedStrings
* object.
*/
public String[] toStringArray()
{
String[] array = new String[string_count];
System.arraycopy(strings, 0, array, 0, string_count);
return array;
}
/**
* Returns a sorted String[] from the String[] passed.
*/
public static String[] sort(String[] input)
{
SortedStrings new_strings = new SortedStrings(input);
return new_strings.toStringArray();
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ini/SortedStrings.java | Java | asf20 | 9,635 |
/*
* Array.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ini;
/**
* This class represents an array of objects.
*
* @author Jeremy Cloud
* @version 1.0.0
*/
public class Array
{
public static Object[] copy(Object[] sors, Object[] dest)
{
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static String[] doubleArray(String[] sors)
{
System.out.print("** doubling string array... ");
int new_size = (sors.length <= 8 ? 16 : sors.length << 1);
String[] dest = new String[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
System.out.println("done **.");
return dest;
}
public static int[] doubleArray(int[] sors)
{
int new_size = (sors.length < 8 ? 16 : sors.length << 1);
int[] dest = new int[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static int[] grow(int[] sors, double growth_rate)
{
int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1);
int[] dest = new int[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static boolean[] grow(boolean[] sors, double growth_rate)
{
int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1);
boolean[] dest = new boolean[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static Object[] grow(Object[] sors, double growth_rate)
{
int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1);
Object[] dest = new Object[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static String[] grow(String[] sors, double growth_rate)
{
int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1);
String[] dest = new String[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
/**
* @param start - inclusive
* @param end - exclusive
*/
public static void shiftUp(Object[] array, int start, int end)
{
int count = end - start;
if (count > 0) System.arraycopy(array, start, array, start + 1, count);
}
/**
* @param start - inclusive
* @param end - exclusive
*/
public static void shiftDown(Object[] array, int start, int end)
{
int count = end - start;
if (count > 0) System.arraycopy(array, start, array, start - 1, count);
}
public static void shift(Object[] array, int start, int amount)
{
int count = array.length - start - (amount > 0 ? amount : 0);
System.arraycopy(array, start, array, start + amount, count);
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ini/Array.java | Java | asf20 | 3,939 |
/*
* BMPLoader.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
import java.awt.image.MemoryImageSource;
import java.io.IOException;
import java.io.InputStream;
/**
* A decoder for Windows bitmap (.BMP) files.
* Compression not supported.
*/
public class BMPLoader
{
private InputStream is;
private int curPos = 0;
private int bitmapOffset; // starting position of image data
private int width; // image width in pixels
private int height; // image height in pixels
private short bitsPerPixel; // 1, 4, 8, or 24 (no color map)
private int compression; // 0 (none), 1 (8-bit RLE), or 2 (4-bit RLE)
private int actualSizeOfBitmap;
private int scanLineSize;
private int actualColorsUsed;
private byte r[], g[], b[]; // color palette
private int noOfEntries;
private byte[] byteData; // Unpacked data
private int[] intData; // Unpacked data
public BMPLoader()
{
}
public Image getBMPImage(InputStream stream) throws Exception
{
read(stream);
return Toolkit.getDefaultToolkit().createImage(getImageSource());
}
protected int readInt() throws IOException
{
int b1 = is.read();
int b2 = is.read();
int b3 = is.read();
int b4 = is.read();
curPos += 4;
return ((b4 << 24) + (b3 << 16) + (b2 << 8) + (b1 << 0));
}
protected short readShort() throws IOException
{
int b1 = is.read();
int b2 = is.read();
curPos += 4;
return (short) ((b2 << 8) + b1);
}
protected void getFileHeader() throws IOException, Exception
{
// Actual contents (14 bytes):
short fileType = 0x4d42;// always "BM"
int fileSize; // size of file in bytes
short reserved1 = 0; // always 0
short reserved2 = 0; // always 0
fileType = readShort();
if (fileType != 0x4d42) throw new Exception("Not a BMP file"); // wrong file type
fileSize = readInt();
reserved1 = readShort();
reserved2 = readShort();
bitmapOffset = readInt();
}
protected void getBitmapHeader() throws IOException
{
// Actual contents (40 bytes):
int size; // size of this header in bytes
short planes; // no. of color planes: always 1
int sizeOfBitmap; // size of bitmap in bytes (may be 0: if so, calculate)
int horzResolution; // horizontal resolution, pixels/meter (may be 0)
int vertResolution; // vertical resolution, pixels/meter (may be 0)
int colorsUsed; // no. of colors in palette (if 0, calculate)
int colorsImportant; // no. of important colors (appear first in palette) (0 means all are important)
boolean topDown;
int noOfPixels;
size = readInt();
width = readInt();
height = readInt();
planes = readShort();
bitsPerPixel = readShort();
compression = readInt();
sizeOfBitmap = readInt();
horzResolution = readInt();
vertResolution = readInt();
colorsUsed = readInt();
colorsImportant = readInt();
topDown = (height < 0);
noOfPixels = width * height;
// Scan line is padded with zeroes to be a multiple of four bytes
scanLineSize = ((width * bitsPerPixel + 31) / 32) * 4;
if (sizeOfBitmap != 0) actualSizeOfBitmap = sizeOfBitmap;
else
// a value of 0 doesn't mean zero - it means we have to calculate it
actualSizeOfBitmap = scanLineSize * height;
if (colorsUsed != 0) actualColorsUsed = colorsUsed;
else
// a value of 0 means we determine this based on the bits per pixel
if (bitsPerPixel < 16) actualColorsUsed = 1 << bitsPerPixel;
else actualColorsUsed = 0; // no palette
}
protected void getPalette() throws IOException
{
noOfEntries = actualColorsUsed;
//IJ.write("noOfEntries: " + noOfEntries);
if (noOfEntries > 0)
{
r = new byte[noOfEntries];
g = new byte[noOfEntries];
b = new byte[noOfEntries];
int reserved;
for (int i = 0; i < noOfEntries; i++)
{
b[i] = (byte) is.read();
g[i] = (byte) is.read();
r[i] = (byte) is.read();
reserved = is.read();
curPos += 4;
}
}
}
protected void unpack(byte[] rawData, int rawOffset, int[] intData, int intOffset, int w)
{
int j = intOffset;
int k = rawOffset;
int mask = 0xff;
for (int i = 0; i < w; i++)
{
int b0 = (((int) (rawData[k++])) & mask);
int b1 = (((int) (rawData[k++])) & mask) << 8;
int b2 = (((int) (rawData[k++])) & mask) << 16;
intData[j] = 0xff000000 | b0 | b1 | b2;
j++;
}
}
protected void unpack(byte[] rawData, int rawOffset, int bpp, byte[] byteData, int byteOffset, int w) throws Exception
{
int j = byteOffset;
int k = rawOffset;
byte mask;
int pixPerByte;
switch (bpp)
{
case 1:
mask = (byte) 0x01;
pixPerByte = 8;
break;
case 4:
mask = (byte) 0x0f;
pixPerByte = 2;
break;
case 8:
mask = (byte) 0xff;
pixPerByte = 1;
break;
default:
throw new Exception("Unsupported bits-per-pixel value");
}
for (int i = 0;;)
{
int shift = 8 - bpp;
for (int ii = 0; ii < pixPerByte; ii++)
{
byte br = rawData[k];
br >>= shift;
byteData[j] = (byte) (br & mask);
//System.out.println("Setting byteData[" + j + "]=" + Test.byteToHex(byteData[j]));
j++;
i++;
if (i == w) return;
shift -= bpp;
}
k++;
}
}
protected int readScanLine(byte[] b, int off, int len) throws IOException
{
int bytesRead = 0;
int l = len;
int r = 0;
while (len > 0)
{
bytesRead = is.read(b, off, len);
if (bytesRead == -1) return r == 0 ? -1 : r;
if (bytesRead == len) return l;
len -= bytesRead;
off += bytesRead;
r += bytesRead;
}
return l;
}
protected void getPixelData() throws IOException, Exception
{
byte[] rawData; // the raw unpacked data
// Skip to the start of the bitmap data (if we are not already there)
long skip = bitmapOffset - curPos;
if (skip > 0)
{
is.skip(skip);
curPos += skip;
}
int len = scanLineSize;
if (bitsPerPixel > 8) intData = new int[width * height];
else byteData = new byte[width * height];
rawData = new byte[actualSizeOfBitmap];
int rawOffset = 0;
int offset = (height - 1) * width;
for (int i = height - 1; i >= 0; i--)
{
int n = readScanLine(rawData, rawOffset, len);
if (n < len) throw new Exception("Scan line ended prematurely after " + n + " bytes");
if (bitsPerPixel > 8)
{
// Unpack and create one int per pixel
unpack(rawData, rawOffset, intData, offset, width);
}
else
{
// Unpack and create one byte per pixel
unpack(rawData, rawOffset, bitsPerPixel, byteData, offset, width);
}
rawOffset += len;
offset -= width;
}
}
public void read(InputStream is) throws IOException, Exception
{
this.is = is;
getFileHeader();
getBitmapHeader();
if (compression != 0) throw new Exception("BMP Compression not supported");
getPalette();
getPixelData();
}
public MemoryImageSource getImageSource()
{
ColorModel cm;
MemoryImageSource mis;
if (noOfEntries > 0)
{
// There is a color palette; create an IndexColorModel
cm = new IndexColorModel(bitsPerPixel, noOfEntries, r, g, b);
}
else
{
// There is no palette; use the default RGB color model
cm = ColorModel.getRGBdefault();
}
// Create MemoryImageSource
if (bitsPerPixel > 8)
{
// use one int per pixel
mis = new MemoryImageSource(width, height, cm, intData, 0, width);
}
else
{
// use one byte per pixel
mis = new MemoryImageSource(width, height, cm, byteData, 0, width);
}
return mis; // this can be used by JComponent.createImage()
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/BMPLoader.java | Java | asf20 | 10,316 |
/*
* FileNameFilter.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util;
import java.io.File;
import java.util.ArrayList;
import java.util.StringTokenizer;
/**
* FileName filter that works for both javax.swing.filechooser and java.io.
*/
public class FileNameFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter
{
protected java.util.List extensions = new ArrayList();
protected String default_extension = null;
protected String description;
protected boolean allowDir = true;
/**
* Constructs the list of extensions out of a string of comma-separated
* elements, each of which represents one extension.
*
* @param ext the list of comma-separated extensions
*/
public FileNameFilter(String ext, String description)
{
this(ext, description, true);
}
public FileNameFilter(String ext, String description, boolean allowDir)
{
this.description = description;
this.allowDir = allowDir;
StringTokenizer st = new StringTokenizer(ext, ", ");
String extension;
while (st.hasMoreTokens())
{
extension = st.nextToken();
extensions.add(extension);
if (default_extension == null) default_extension = extension;
}
}
/**
* determines if the filename is an acceptable one. If a
* filename ends with one of the extensions the filter was
* initialized with, then the function returns true. if not,
* the function returns false.
*
* @param dir the directory the file is in
* @return true if the filename has a valid extension, false otherwise
*/
public boolean accept(File dir)
{
for (int i = 0; i < extensions.size(); i++)
{
if (allowDir)
{
if (dir.isDirectory() || dir.getName().endsWith("." + (String) extensions.get(i))) return true;
}
else
{
if (dir.getName().endsWith("." + (String) extensions.get(i))) return true;
}
}
return extensions.size() == 0;
}
/**
* Returns the default extension.
*
* @return the default extension
*/
public String getDefaultExtension()
{
return default_extension;
}
public void setDefaultExtension(String ext)
{
default_extension = ext;
}
public String getDescription()
{
return description;
}
} | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/FileNameFilter.java | Java | asf20 | 3,562 |
/*
* FileUtil.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
/**
* @author Scott Pennell
*/
public class FileUtil
{
private static List supportedExtensions = null;
public static File[] findFilesRecursively(File directory)
{
if (directory.isFile())
{
File[] f = new File[1];
f[0] = directory;
return f;
}
List list = new ArrayList();
addSongsRecursive(list, directory);
return ((File[]) list.toArray(new File[list.size()]));
}
private static void addSongsRecursive(List found, File rootDir)
{
if (rootDir == null) return; // we do not want waste time
File[] files = rootDir.listFiles();
if (files == null) return;
for (int i = 0; i < files.length; i++)
{
File file = new File(rootDir, files[i].getName());
if (file.isDirectory()) addSongsRecursive(found, file);
else
{
if (isMusicFile(files[i]))
{
found.add(file);
}
}
}
}
public static boolean isMusicFile(File f)
{
List exts = getSupportedExtensions();
int sz = exts.size();
String ext;
String name = f.getName();
for (int i = 0; i < sz; i++)
{
ext = (String) exts.get(i);
if (ext.equals(".wsz") || ext.equals(".m3u")) continue;
if (name.endsWith(ext)) return true;
}
return false;
}
public static List getSupportedExtensions()
{
if (supportedExtensions == null)
{
String ext = Config.getInstance().getExtensions();
StringTokenizer st = new StringTokenizer(ext, ",");
supportedExtensions = new ArrayList();
while (st.hasMoreTokens())
supportedExtensions.add("." + st.nextElement());
}
return (supportedExtensions);
}
public static String getSupprtedExtensions()
{
List exts = getSupportedExtensions();
StringBuffer s = new StringBuffer();
int sz = exts.size();
String ext;
for (int i = 0; i < sz; i++)
{
ext = (String) exts.get(i);
if (ext.equals(".wsz") || ext.equals(".m3u")) continue;
if (i == 0) s.append(ext);
else s.append(";").append(ext);
}
return s.toString();
}
public static String padString(String s, int length)
{
return padString(s, ' ', length);
}
public static String padString(String s, char padChar, int length)
{
int slen, numPads = 0;
if (s == null)
{
s = "";
numPads = length;
}
else if ((slen = s.length()) > length)
{
s = s.substring(0, length);
}
else if (slen < length)
{
numPads = length - slen;
}
if (numPads == 0) return s;
char[] c = new char[numPads];
Arrays.fill(c, padChar);
return s + new String(c);
}
public static String rightPadString(String s, int length)
{
return (rightPadString(s, ' ', length));
}
public static String rightPadString(String s, char padChar, int length)
{
int slen, numPads = 0;
if (s == null)
{
s = "";
numPads = length;
}
else if ((slen = s.length()) > length)
{
s = s.substring(length);
}
else if (slen < length)
{
numPads = length - slen;
}
if (numPads == 0) return (s);
char[] c = new char[numPads];
Arrays.fill(c, padChar);
return new String(c) + s;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/FileUtil.java | Java | asf20 | 5,062 |
/*
* Config.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util;
import java.io.File;
import java.util.StringTokenizer;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.util.ini.Configuration;
/**
* This class provides all parameters for jlGui coming from a file.
*/
public class Config
{
public static String[] protocols = { "http:", "file:", "ftp:", "https:", "ftps:", "jar:" };
public static String TAGINFO_POLICY_FILE = "file";
public static String TAGINFO_POLICY_ALL = "all";
public static String TAGINFO_POLICY_NONE = "none";
private static String CONFIG_FILE_NAME = "jlgui.ini";
private Configuration _config = null;
// configuration keys
private static final String LAST_URL = "last_url",
LAST_DIR = "last_dir",
ORIGINE_X = "origine_x",
ORIGINE_Y = "origine_y",
LAST_SKIN = "last_skin",
LAST_SKIN_DIR = "last_skin_dir",
EXTENSIONS = "allowed_extensions",
PLAYLIST_IMPL = "playlist_impl",
TAGINFO_MPEG_IMPL = "taginfo_mpeg_impl",
TAGINFO_OGGVORBIS_IMPL = "taginfo_oggvorbis_impl",
TAGINFO_APE_IMPL = "taginfo_ape_impl",
TAGINFO_FLAC_IMPL = "taginfo_flac_impl",
LAST_PLAYLIST = "last_playlist",
PROXY_SERVER = "proxy_server",
PROXY_PORT = "proxy_port",
PROXY_LOGIN = "proxy_login",
PROXY_PASSWORD = "proxy_password",
PLAYLIST_ENABLED = "playlist_enabled",
SHUFFLE_ENABLED = "shuffle_enabled",
REPEAT_ENABLED = "repeat_enabled",
EQUALIZER_ENABLED = "equalizer_enabled",
EQUALIZER_ON = "equalizer_on",
EQUALIZER_AUTO = "equalizer_auto",
LAST_EQUALIZER = "last_equalizer",
SCREEN_LIMIT = "screen_limit",
TAGINFO_POLICY = "taginfo_policy",
VOLUME_VALUE = "volume_value",
AUDIO_DEVICE = "audio_device",
VISUAL_MODE = "visual_mode";
private static Config _instance = null;
private String _audioDevice = "";
private String _visualMode = "";
private String _extensions = "m3u,pls,wsz,snd,aifc,aif,wav,au,mp1,mp2,mp3,ogg,spx,flac,ape,mac";
private String _lastUrl = "";
private String _lastDir = "";
private String _lastSkinDir = "";
private String _lastEqualizer = "";
private String _defaultSkin = "";
private String _playlist = "javazoom.jlgui.player.amp.playlist.BasePlaylist";
private String _taginfoMpeg = "javazoom.jlgui.player.amp.tag.MpegInfo";
private String _taginfoOggVorbis = "javazoom.jlgui.player.amp.tag.OggVorbisInfo";
private String _taginfoAPE = "javazoom.jlgui.player.amp.tag.APEInfo";
private String _taginfoFlac = "javazoom.jlgui.player.amp.tag.FlacInfo";
private String _playlistFilename = "";
private int _x = 0;
private int _y = 0;
private String _proxyServer = "";
private String _proxyLogin = "";
private String _proxyPassword = "";
private int _proxyPort = -1;
private int _volume = -1;
private boolean _playlistEnabled = false;
private boolean _shuffleEnabled = false;
private boolean _repeatEnabled = false;
private boolean _equalizerEnabled = false;
private boolean _equalizerOn = false;
private boolean _equalizerAuto = false;
private boolean _screenLimit = false;
private String _taginfoPolicy = TAGINFO_POLICY_FILE;
private JFrame topParent = null;
private ImageIcon iconParent = null;
private Config()
{
}
/**
* Returns Config instance.
*/
public synchronized static Config getInstance()
{
if (_instance == null)
{
_instance = new Config();
}
return _instance;
}
public void setTopParent(JFrame frame)
{
topParent = frame;
}
public JFrame getTopParent()
{
if (topParent == null)
{
topParent = new JFrame();
}
return topParent;
}
public void setIconParent(ImageIcon icon)
{
iconParent = icon;
}
public ImageIcon getIconParent()
{
return iconParent;
}
/**
* Returns JavaSound audio device.
* @return String
*/
public String getAudioDevice()
{
return _audioDevice;
}
/**
* Set JavaSound audio device.
* @param dev String
*/
public void setAudioDevice(String dev)
{
_audioDevice = dev;
}
/**
* Return visual mode.
* @return
*/
public String getVisualMode()
{
return _visualMode;
}
/**
* Set visual mode.
* @param mode
*/
public void setVisualMode(String mode)
{
_visualMode = mode;
}
/**
* Returns playlist filename.
*/
public String getPlaylistFilename()
{
return _playlistFilename;
}
/**
* Sets playlist filename.
*/
public void setPlaylistFilename(String pl)
{
_playlistFilename = pl;
}
/**
* Returns last equalizer values.
*/
public int[] getLastEqualizer()
{
int[] vals = null;
if ((_lastEqualizer != null) && (!_lastEqualizer.equals("")))
{
vals = new int[11];
int i = 0;
StringTokenizer st = new StringTokenizer(_lastEqualizer, ",");
while (st.hasMoreTokens())
{
String v = st.nextToken();
vals[i++] = Integer.parseInt(v);
}
}
return vals;
}
/**
* Sets last equalizer values.
*/
public void setLastEqualizer(int[] vals)
{
if (vals != null)
{
String dump = "";
for (int i = 0; i < vals.length; i++)
{
dump = dump + vals[i] + ",";
}
_lastEqualizer = dump.substring(0, (dump.length() - 1));
}
}
/**
* Return screen limit flag.
*
* @return is screen limit flag
*/
public boolean isScreenLimit()
{
return _screenLimit;
}
/**
* Set screen limit flag.
*
* @param b
*/
public void setScreenLimit(boolean b)
{
_screenLimit = b;
}
/**
* Returns last URL.
*/
public String getLastURL()
{
return _lastUrl;
}
/**
* Sets last URL.
*/
public void setLastURL(String url)
{
_lastUrl = url;
}
/**
* Returns last Directory.
*/
public String getLastDir()
{
if ((_lastDir != null) && (!_lastDir.endsWith(File.separator)))
{
_lastDir = _lastDir + File.separator;
}
return _lastDir;
}
/**
* Sets last Directory.
*/
public void setLastDir(String dir)
{
_lastDir = dir;
if ((_lastDir != null) && (!_lastDir.endsWith(File.separator)))
{
_lastDir = _lastDir + File.separator;
}
}
/**
* Returns last skin directory.
*/
public String getLastSkinDir()
{
if ((_lastSkinDir != null) && (!_lastSkinDir.endsWith(File.separator)))
{
_lastSkinDir = _lastSkinDir + File.separator;
}
return _lastSkinDir;
}
/**
* Sets last skin directory.
*/
public void setLastSkinDir(String dir)
{
_lastSkinDir = dir;
if ((_lastSkinDir != null) && (!_lastSkinDir.endsWith(File.separator)))
{
_lastSkinDir = _lastSkinDir + File.separator;
}
}
/**
* Returns audio extensions.
*/
public String getExtensions()
{
return _extensions;
}
/**
* Returns proxy server.
*/
public String getProxyServer()
{
return _proxyServer;
}
/**
* Returns proxy port.
*/
public int getProxyPort()
{
return _proxyPort;
}
/**
* Returns volume value.
*/
public int getVolume()
{
return _volume;
}
/**
* Returns volume value.
*/
public void setVolume(int vol)
{
_volume = vol;
}
/**
* Returns X location.
*/
public int getXLocation()
{
return _x;
}
/**
* Returns Y location.
*/
public int getYLocation()
{
return _y;
}
/**
* Sets X,Y location.
*/
public void setLocation(int x, int y)
{
_x = x;
_y = y;
}
/**
* Sets Proxy info.
*/
public void setProxy(String url, int port, String login, String password)
{
_proxyServer = url;
_proxyPort = port;
_proxyLogin = login;
_proxyPassword = password;
}
/**
* Enables Proxy.
*/
public boolean enableProxy()
{
if ((_proxyServer != null) && (!_proxyServer.equals("")))
{
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", _proxyServer);
System.getProperties().put("proxyPort", "" + _proxyPort);
return true;
}
else return false;
}
/**
* Returns PlaylistUI state.
*/
public boolean isPlaylistEnabled()
{
return _playlistEnabled;
}
/**
* Sets PlaylistUI state.
*/
public void setPlaylistEnabled(boolean ena)
{
_playlistEnabled = ena;
}
/**
* Returns ShuffleUI state.
*/
public boolean isShuffleEnabled()
{
return _shuffleEnabled;
}
/**
* Sets ShuffleUI state.
*/
public void setShuffleEnabled(boolean ena)
{
_shuffleEnabled = ena;
}
/**
* Returns RepeatUI state.
*/
public boolean isRepeatEnabled()
{
return _repeatEnabled;
}
/**
* Sets RepeatUI state.
*/
public void setRepeatEnabled(boolean ena)
{
_repeatEnabled = ena;
}
/**
* Returns EqualizerUI state.
*/
public boolean isEqualizerEnabled()
{
return _equalizerEnabled;
}
/**
* Sets EqualizerUI state.
*/
public void setEqualizerEnabled(boolean ena)
{
_equalizerEnabled = ena;
}
/**
* Returns default skin.
*/
public String getDefaultSkin()
{
return _defaultSkin;
}
/**
* Sets default skin.
*/
public void setDefaultSkin(String skin)
{
_defaultSkin = skin;
}
/**
* Returns playlist classname implementation.
*/
public String getPlaylistClassName()
{
return _playlist;
}
/**
* Set playlist classname implementation.
*/
public void setPlaylistClassName(String s)
{
_playlist = s;
}
/**
* Returns Mpeg TagInfo classname implementation.
*/
public String getMpegTagInfoClassName()
{
return _taginfoMpeg;
}
/**
* Returns Ogg Vorbis TagInfo classname implementation.
*/
public String getOggVorbisTagInfoClassName()
{
return _taginfoOggVorbis;
}
/**
* Returns APE TagInfo classname implementation.
*/
public String getAPETagInfoClassName()
{
return _taginfoAPE;
}
/**
* Returns Ogg Vorbis TagInfo classname implementation.
*/
public String getFlacTagInfoClassName()
{
return _taginfoFlac;
}
/**
* Loads configuration for the specified file.
*/
public void load(String configfile)
{
CONFIG_FILE_NAME = configfile;
load();
}
/**
* Loads configuration.
*/
public void load()
{
_config = new Configuration(CONFIG_FILE_NAME);
// Creates config entries if needed.
if (_config.get(AUDIO_DEVICE) == null) _config.add(AUDIO_DEVICE, _audioDevice);
if (_config.get(VISUAL_MODE) == null) _config.add(VISUAL_MODE, _visualMode);
if (_config.get(LAST_URL) == null) _config.add(LAST_URL, _lastUrl);
if (_config.get(LAST_EQUALIZER) == null) _config.add(LAST_EQUALIZER, _lastEqualizer);
if (_config.get(LAST_DIR) == null) _config.add(LAST_DIR, _lastDir);
if (_config.get(LAST_SKIN_DIR) == null) _config.add(LAST_SKIN_DIR, _lastSkinDir);
if (_config.get(TAGINFO_POLICY) == null) _config.add(TAGINFO_POLICY, _taginfoPolicy);
if (_config.getInt(ORIGINE_X) == -1) _config.add(ORIGINE_X, _x);
if (_config.getInt(ORIGINE_Y) == -1) _config.add(ORIGINE_Y, _y);
if (_config.get(LAST_SKIN) == null) _config.add(LAST_SKIN, _defaultSkin);
if (_config.get(LAST_PLAYLIST) == null) _config.add(LAST_PLAYLIST, _playlistFilename);
if (_config.get(PLAYLIST_IMPL) == null) _config.add(PLAYLIST_IMPL, _playlist);
if (_config.get(TAGINFO_MPEG_IMPL) == null) _config.add(TAGINFO_MPEG_IMPL, _taginfoMpeg);
if (_config.get(TAGINFO_OGGVORBIS_IMPL) == null) _config.add(TAGINFO_OGGVORBIS_IMPL, _taginfoOggVorbis);
if (_config.get(TAGINFO_APE_IMPL) == null) _config.add(TAGINFO_APE_IMPL, _taginfoAPE);
if (_config.get(TAGINFO_FLAC_IMPL) == null) _config.add(TAGINFO_FLAC_IMPL, _taginfoFlac);
if (_config.get(EXTENSIONS) == null) _config.add(EXTENSIONS, _extensions);
if (_config.get(PROXY_SERVER) == null) _config.add(PROXY_SERVER, _proxyServer);
if (_config.getInt(PROXY_PORT) == -1) _config.add(PROXY_PORT, _proxyPort);
if (_config.getInt(VOLUME_VALUE) == -1) _config.add(VOLUME_VALUE, _volume);
if (_config.get(PROXY_LOGIN) == null) _config.add(PROXY_LOGIN, _proxyLogin);
if (_config.get(PROXY_PASSWORD) == null) _config.add(PROXY_PASSWORD, _proxyPassword);
if (!_config.getBoolean(PLAYLIST_ENABLED)) _config.add(PLAYLIST_ENABLED, _playlistEnabled);
if (!_config.getBoolean(SHUFFLE_ENABLED)) _config.add(SHUFFLE_ENABLED, _shuffleEnabled);
if (!_config.getBoolean(REPEAT_ENABLED)) _config.add(REPEAT_ENABLED, _repeatEnabled);
if (!_config.getBoolean(EQUALIZER_ENABLED)) _config.add(EQUALIZER_ENABLED, _equalizerEnabled);
if (!_config.getBoolean(EQUALIZER_ON)) _config.add(EQUALIZER_ON, _equalizerOn);
if (!_config.getBoolean(EQUALIZER_AUTO)) _config.add(EQUALIZER_AUTO, _equalizerAuto);
if (!_config.getBoolean(SCREEN_LIMIT)) _config.add(SCREEN_LIMIT, _screenLimit);
// Reads config entries
_audioDevice = _config.get(AUDIO_DEVICE, _audioDevice);
_visualMode = _config.get(VISUAL_MODE, _visualMode);
_lastUrl = _config.get(LAST_URL, _lastUrl);
_lastEqualizer = _config.get(LAST_EQUALIZER, _lastEqualizer);
_lastDir = _config.get(LAST_DIR, _lastDir);
_lastSkinDir = _config.get(LAST_SKIN_DIR, _lastSkinDir);
_x = _config.getInt(ORIGINE_X, _x);
_y = _config.getInt(ORIGINE_Y, _y);
_defaultSkin = _config.get(LAST_SKIN, _defaultSkin);
_playlistFilename = _config.get(LAST_PLAYLIST, _playlistFilename);
_taginfoPolicy = _config.get(TAGINFO_POLICY, _taginfoPolicy);
_extensions = _config.get(EXTENSIONS, _extensions);
_playlist = _config.get(PLAYLIST_IMPL, _playlist);
_taginfoMpeg = _config.get(TAGINFO_MPEG_IMPL, _taginfoMpeg);
_taginfoOggVorbis = _config.get(TAGINFO_OGGVORBIS_IMPL, _taginfoOggVorbis);
_taginfoAPE = _config.get(TAGINFO_APE_IMPL, _taginfoAPE);
_taginfoFlac = _config.get(TAGINFO_FLAC_IMPL, _taginfoFlac);
_proxyServer = _config.get(PROXY_SERVER, _proxyServer);
_proxyPort = _config.getInt(PROXY_PORT, _proxyPort);
_volume = _config.getInt(VOLUME_VALUE, _volume);
_proxyLogin = _config.get(PROXY_LOGIN, _proxyLogin);
_proxyPassword = _config.get(PROXY_PASSWORD, _proxyPassword);
_playlistEnabled = _config.getBoolean(PLAYLIST_ENABLED, _playlistEnabled);
_shuffleEnabled = _config.getBoolean(SHUFFLE_ENABLED, _shuffleEnabled);
_repeatEnabled = _config.getBoolean(REPEAT_ENABLED, _repeatEnabled);
_equalizerEnabled = _config.getBoolean(EQUALIZER_ENABLED, _equalizerEnabled);
_equalizerOn = _config.getBoolean(EQUALIZER_ON, _equalizerOn);
_equalizerAuto = _config.getBoolean(EQUALIZER_AUTO, _equalizerAuto);
_screenLimit = _config.getBoolean(SCREEN_LIMIT, _screenLimit);
}
/**
* Saves configuration.
*/
public void save()
{
if (_config != null)
{
_config.add(ORIGINE_X, _x);
_config.add(ORIGINE_Y, _y);
if (_lastDir != null) _config.add(LAST_DIR, _lastDir);
if (_lastSkinDir != null) _config.add(LAST_SKIN_DIR, _lastSkinDir);
if (_audioDevice != null) _config.add(AUDIO_DEVICE, _audioDevice);
if (_visualMode != null) _config.add(VISUAL_MODE, _visualMode);
if (_lastUrl != null) _config.add(LAST_URL, _lastUrl);
if (_lastEqualizer != null) _config.add(LAST_EQUALIZER, _lastEqualizer);
if (_playlistFilename != null) _config.add(LAST_PLAYLIST, _playlistFilename);
if (_playlist != null) _config.add(PLAYLIST_IMPL, _playlist);
if (_defaultSkin != null) _config.add(LAST_SKIN, _defaultSkin);
if (_taginfoPolicy != null) _config.add(TAGINFO_POLICY, _taginfoPolicy);
if (_volume != -1) _config.add(VOLUME_VALUE, _volume);
_config.add(PLAYLIST_ENABLED, _playlistEnabled);
_config.add(SHUFFLE_ENABLED, _shuffleEnabled);
_config.add(REPEAT_ENABLED, _repeatEnabled);
_config.add(EQUALIZER_ENABLED, _equalizerEnabled);
_config.add(EQUALIZER_ON, _equalizerOn);
_config.add(EQUALIZER_AUTO, _equalizerAuto);
_config.add(SCREEN_LIMIT, _screenLimit);
_config.save();
}
}
/**
* @return equalizer auto flag
*/
public boolean isEqualizerAuto()
{
return _equalizerAuto;
}
/**
* @return equalizer on flag
*/
public boolean isEqualizerOn()
{
return _equalizerOn;
}
/**
* @param b
*/
public void setEqualizerAuto(boolean b)
{
_equalizerAuto = b;
}
/**
* @param b
*/
public void setEqualizerOn(boolean b)
{
_equalizerOn = b;
}
public static boolean startWithProtocol(String input)
{
boolean ret = false;
if (input != null)
{
input = input.toLowerCase();
for (int i = 0; i < protocols.length; i++)
{
if (input.startsWith(protocols[i]))
{
ret = true;
break;
}
}
}
return ret;
}
/**
* @return tag info policy
*/
public String getTaginfoPolicy()
{
return _taginfoPolicy;
}
/**
* @param string
*/
public void setTaginfoPolicy(String string)
{
_taginfoPolicy = string;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/Config.java | Java | asf20 | 20,563 |
/*
* FileSelector.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.Loader;
/**
* This class is used to select a file or directory for loading or saving.
*/
public class FileSelector
{
public static final int OPEN = 1;
public static final int SAVE = 2;
public static final int SAVE_AS = 3;
public static final int DIRECTORY = 4;
private File[] files = null;
private File directory = null;
private static FileSelector instance = null;
public File[] getFiles()
{
return files;
}
public File getDirectory()
{
return directory;
}
public static final FileSelector getInstance()
{
if (instance == null) instance = new FileSelector();
return instance;
}
/**
* Opens a dialog box so that the user can search for a file
* with the given extension and returns the filename selected.
*
* @param extensions the extension of the filename to be selected,
* or "" if any filename can be used
* @param directory the folder to be put in the starting directory
* @param mode the action that will be performed on the file, used to tell what
* files are valid
* @return the selected file
*/
public static File[] selectFile(Loader loader, int mode, boolean multiple, String extensions, String description, File directory)
{
return selectFile(loader, mode, multiple, null, extensions, description, null, directory);
}
/**
* Opens a dialog box so that the user can search for a file
* with the given extension and returns the filename selected.
*
* @param extensions the extension of the filename to be selected,
* or "" if any filename can be used
* @param titlePrefix the string to be put in the title, followed by : SaveAs
* @param mode the action that will be performed on the file, used to tell what
* files are valid
* @param defaultFile the default file
* @param directory the string to be put in the starting directory
* @return the selected filename
*/
public static File[] selectFile(Loader loader, int mode, boolean multiple, File defaultFile, String extensions, String description, String titlePrefix, File directory)
{
JFrame mainWindow = null;
if (loader instanceof JFrame)
{
mainWindow = (JFrame) loader;
}
JFileChooser filePanel = new JFileChooser();
StringBuffer windowTitle = new StringBuffer();
if (titlePrefix != null && titlePrefix.length() > 0) windowTitle.append(titlePrefix).append(": ");
switch (mode)
{
case OPEN:
windowTitle.append("Open");
break;
case SAVE:
windowTitle.append("Save");
break;
case SAVE_AS:
windowTitle.append("Save As");
break;
case DIRECTORY:
windowTitle.append("Choose Directory");
break;
}
filePanel.setDialogTitle(windowTitle.toString());
FileNameFilter filter = new FileNameFilter(extensions, description);
filePanel.setFileFilter(filter);
if (defaultFile != null) filePanel.setSelectedFile(defaultFile);
if (directory != null) filePanel.setCurrentDirectory(directory);
filePanel.setMultiSelectionEnabled(multiple);
int retVal = -1;
switch (mode)
{
case OPEN:
filePanel.setDialogType(JFileChooser.OPEN_DIALOG);
retVal = filePanel.showOpenDialog(mainWindow);
break;
case SAVE:
filePanel.setDialogType(JFileChooser.SAVE_DIALOG);
retVal = filePanel.showSaveDialog(mainWindow);
break;
case SAVE_AS:
filePanel.setDialogType(JFileChooser.SAVE_DIALOG);
retVal = filePanel.showSaveDialog(mainWindow);
break;
case DIRECTORY:
filePanel.setDialogType(JFileChooser.SAVE_DIALOG);
filePanel.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
retVal = filePanel.showDialog(mainWindow, "Select");
break;
}
if (retVal == JFileChooser.APPROVE_OPTION)
{
if (multiple) getInstance().files = filePanel.getSelectedFiles();
else
{
getInstance().files = new File[1];
getInstance().files[0] = filePanel.getSelectedFile();
}
getInstance().directory = filePanel.getCurrentDirectory();
}
else
{
getInstance().files = null;
}
return getInstance().files;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/FileSelector.java | Java | asf20 | 6,105 |
/*
* Preferences.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Method;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.border.EmptyBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javazoom.jlgui.player.amp.PlayerUI;
import javazoom.jlgui.player.amp.util.Config;
public class Preferences extends JFrame implements TreeSelectionListener, ActionListener
{
private static Preferences instance = null;
private JTree tree = null;
private ResourceBundle bundle = null;
private DefaultMutableTreeNode options = null;
private DefaultMutableTreeNode filetypes = null;
private DefaultMutableTreeNode device = null;
private DefaultMutableTreeNode proxy = null;
private DefaultMutableTreeNode plugins = null;
private DefaultMutableTreeNode visual = null;
private DefaultMutableTreeNode visuals = null;
private DefaultMutableTreeNode output = null;
//private DefaultMutableTreeNode drm = null;
private DefaultMutableTreeNode skins = null;
private DefaultMutableTreeNode browser = null;
private JScrollPane treePane = null;
private JScrollPane workPane = null;
private JButton close = null;
private PlayerUI player = null;
public Preferences(PlayerUI player)
{
super();
this.player = player;
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
ImageIcon icon = Config.getInstance().getIconParent();
if (icon != null) setIconImage(icon.getImage());
}
public static synchronized Preferences getInstance(PlayerUI player)
{
if (instance == null)
{
instance = new Preferences(player);
instance.loadUI();
}
return instance;
}
private void loadUI()
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/preferences");
setTitle(getResource("title"));
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
// Options
if (getResource("tree.options") != null)
{
options = new DefaultMutableTreeNode(getResource("tree.options"));
if (getResource("tree.options.device") != null)
{
device = new DefaultMutableTreeNode();
device.setUserObject(new NodeItem(getResource("tree.options.device"), getResource("tree.options.device.impl")));
options.add(device);
}
if (getResource("tree.options.visual") != null)
{
visual = new DefaultMutableTreeNode();
visual.setUserObject(new NodeItem(getResource("tree.options.visual"), getResource("tree.options.visual.impl")));
options.add(visual);
}
if (getResource("tree.options.filetypes") != null)
{
filetypes = new DefaultMutableTreeNode();
filetypes.setUserObject(new NodeItem(getResource("tree.options.filetypes"), getResource("tree.options.filetypes.impl")));
options.add(filetypes);
}
if (getResource("tree.options.system") != null)
{
proxy = new DefaultMutableTreeNode();
proxy.setUserObject(new NodeItem(getResource("tree.options.system"), getResource("tree.options.system.impl")));
options.add(proxy);
}
root.add(options);
}
// Plugins
if (getResource("tree.plugins") != null)
{
plugins = new DefaultMutableTreeNode(getResource("tree.plugins"));
if (getResource("tree.plugins.visualization") != null)
{
visuals = new DefaultMutableTreeNode();
visuals.setUserObject(new NodeItem(getResource("tree.plugins.visualization"), getResource("tree.plugins.visualization.impl")));
plugins.add(visuals);
}
if (getResource("tree.plugins.output") != null)
{
output = new DefaultMutableTreeNode();
output.setUserObject(new NodeItem(getResource("tree.plugins.output"), getResource("tree.plugins.output.impl")));
plugins.add(output);
}
/*if (getResource("tree.plugins.drm") != null)
{
drm = new DefaultMutableTreeNode();
drm.setUserObject(new NodeItem(getResource("tree.plugins.drm"), getResource("tree.plugins.drm.impl")));
plugins.add(drm);
}*/
root.add(plugins);
}
// Skins
if (getResource("tree.skins") != null)
{
skins = new DefaultMutableTreeNode(getResource("tree.skins"));
if (getResource("tree.skins.browser") != null)
{
browser = new DefaultMutableTreeNode();
browser.setUserObject(new NodeItem(getResource("tree.skins.browser"), getResource("tree.skins.browser.impl")));
skins.add(browser);
}
root.add(skins);
}
tree = new JTree(root);
tree.setRootVisible(false);
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setLeafIcon(null);
renderer.setClosedIcon(null);
renderer.setOpenIcon(null);
tree.setCellRenderer(renderer);
tree.addTreeSelectionListener(this);
int i = 0;
while (i < tree.getRowCount())
{
tree.expandRow(i++);
}
tree.setBorder(new EmptyBorder(1, 4, 1, 2));
GridBagLayout layout = new GridBagLayout();
getContentPane().setLayout(layout);
GridBagConstraints cnts = new GridBagConstraints();
cnts.fill = GridBagConstraints.BOTH;
cnts.weightx = 0.3;
cnts.weighty = 1.0;
cnts.gridx = 0;
cnts.gridy = 0;
treePane = new JScrollPane(tree);
JPanel leftPane = new JPanel();
leftPane.setLayout(new BorderLayout());
leftPane.add(treePane, BorderLayout.CENTER);
if (getResource("button.close") != null)
{
close = new JButton(getResource("button.close"));
close.addActionListener(this);
leftPane.add(close, BorderLayout.SOUTH);
}
getContentPane().add(leftPane, cnts);
cnts.weightx = 1.0;
cnts.gridx = 1;
cnts.gridy = 0;
workPane = new JScrollPane(new JPanel());
getContentPane().add(workPane, cnts);
}
public void valueChanged(TreeSelectionEvent e)
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node == null) return;
if (node.isLeaf())
{
Object nodeItem = node.getUserObject();
if ((nodeItem != null) && (nodeItem instanceof NodeItem))
{
PreferenceItem pane = getPreferenceItem(((NodeItem) nodeItem).getImpl());
if (pane != null)
{
pane.setPlayer(player);
pane.loadUI();
pane.setParentFrame(this);
workPane.setViewportView(pane);
}
}
}
}
public void selectSkinBrowserPane()
{
TreeNode[] path = browser.getPath();
tree.setSelectionPath(new TreePath(path));
}
public void actionPerformed(ActionEvent ev)
{
if (ev.getSource() == close)
{
if (player != null)
{
Config config = player.getConfig();
config.save();
}
dispose();
}
}
/**
* Return I18N value of a given key.
* @param key
* @return
*/
public String getResource(String key)
{
String value = null;
if (key != null)
{
try
{
value = bundle.getString(key);
}
catch (MissingResourceException e)
{
}
}
return value;
}
public PreferenceItem getPreferenceItem(String impl)
{
PreferenceItem item = null;
if (impl != null)
{
try
{
Class aClass = Class.forName(impl);
Method method = aClass.getMethod("getInstance", null);
item = (PreferenceItem) method.invoke(null, null);
}
catch (Exception e)
{
// TODO
}
}
return item;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/Preferences.java | Java | asf20 | 10,396 |
/*
* TypePreference.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
public class TypePreference extends PreferenceItem implements ActionListener, ListSelectionListener
{
private DefaultListModel listModel = null;
private JList types = null;
private JPanel listPane = null;
private JPanel extensionPane = null;
private static TypePreference instance = null;
private TypePreference()
{
listModel = new DefaultListModel();
}
public static TypePreference getInstance()
{
if (instance == null)
{
instance = new TypePreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/type");
setBorder(new TitledBorder(getResource("title")));
loadTypes();
types = new JList(listModel);
types.setBorder(new EmptyBorder(1, 2, 1, 1));
types.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
types.setLayoutOrientation(JList.VERTICAL);
types.setVisibleRowCount(12);
types.addListSelectionListener(this);
JScrollPane listScroller = new JScrollPane(types);
listScroller.setPreferredSize(new Dimension(80, 240));
listPane = new JPanel();
listPane.add(listScroller);
extensionPane = new JPanel();
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints cnts = new GridBagConstraints();
cnts.fill = GridBagConstraints.BOTH;
cnts.gridwidth = 1;
cnts.weightx = 0.30;
cnts.weighty = 1.0;
cnts.gridx = 0;
cnts.gridy = 0;
add(listPane, cnts);
cnts.gridwidth = 1;
cnts.weightx = 0.70;
cnts.weighty = 1.0;
cnts.gridx = 1;
cnts.gridy = 0;
add(extensionPane, cnts);
loaded = true;
}
}
public void actionPerformed(ActionEvent ev)
{
}
public void valueChanged(ListSelectionEvent e)
{
if (e.getValueIsAdjusting() == false)
{
if (types.getSelectedIndex() == -1)
{
}
else
{
}
}
}
private void loadTypes()
{
String extensions = player.getConfig().getExtensions();
StringTokenizer st = new StringTokenizer(extensions, ",");
while (st.hasMoreTokens())
{
String type = st.nextToken();
listModel.addElement(type);
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/TypePreference.java | Java | asf20 | 4,371 |
/*
* EmptyPreference.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import javax.swing.border.TitledBorder;
public class EmptyPreference extends PreferenceItem
{
private static EmptyPreference instance = null;
private EmptyPreference()
{
}
public static EmptyPreference getInstance()
{
if (instance == null)
{
instance = new EmptyPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
setBorder(new TitledBorder(""));
loaded = true;
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/EmptyPreference.java | Java | asf20 | 1,623 |
/*
* SystemPreference.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import java.awt.BorderLayout;
import java.awt.Font;
import java.util.Iterator;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.TreeMap;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
public class SystemPreference extends PreferenceItem
{
private JTextArea info = null;
private boolean loaded = false;
private static SystemPreference instance = null;
private SystemPreference()
{
}
public static SystemPreference getInstance()
{
if (instance == null)
{
instance = new SystemPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/system");
setBorder(new TitledBorder(getResource("title")));
setLayout(new BorderLayout());
info = new JTextArea(16,35);
info.setFont(new Font("Dialog", Font.PLAIN, 11));
info.setEditable(false);
info.setCursor(null);
info.setBorder(new EmptyBorder(1,2,1,1));
Properties props = System.getProperties();
Iterator it = props.keySet().iterator();
TreeMap map = new TreeMap();
while (it.hasNext())
{
String key = (String) it.next();
String value = props.getProperty(key);
map.put(key, value);
}
it = map.keySet().iterator();
while (it.hasNext())
{
String key = (String) it.next();
String value = (String) map.get(key);
info.append(key + "=" + value + "\r\n");
}
JScrollPane infoScroller = new JScrollPane(info);
infoScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
infoScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
add(infoScroller, BorderLayout.CENTER);
info.setCaretPosition(0);
loaded = true;
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/SystemPreference.java | Java | asf20 | 3,371 |
/*
* DevicePreference.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javazoom.jlgui.basicplayer.BasicController;
import javazoom.jlgui.basicplayer.BasicPlayer;
public class DevicePreference extends PreferenceItem implements ActionListener
{
private BasicPlayer bplayer = null;
private static DevicePreference instance = null;
private DevicePreference()
{
}
public static DevicePreference getInstance()
{
if (instance == null)
{
instance = new DevicePreference();
}
return instance;
}
public void loadUI()
{
removeAll();
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/device");
setBorder(new TitledBorder(getResource("title")));
BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS);
setLayout(layout);
BasicController controller = null;
if (player != null) controller = player.getController();
if ((controller != null) && (controller instanceof BasicPlayer))
{
bplayer = (BasicPlayer) controller;
List devices = bplayer.getMixers();
String mixer = bplayer.getMixerName();
ButtonGroup group = new ButtonGroup();
Iterator it = devices.iterator();
while (it.hasNext())
{
String name = (String) it.next();
JRadioButton radio = new JRadioButton(name);
if (name.equals(mixer))
{
radio.setSelected(true);
}
else
{
radio.setSelected(false);
}
group.add(radio);
radio.addActionListener(this);
radio.setAlignmentX(Component.LEFT_ALIGNMENT);
add(radio);
}
JPanel lineInfo = new JPanel();
lineInfo.setLayout(new BoxLayout(lineInfo, BoxLayout.Y_AXIS));
lineInfo.setAlignmentX(Component.LEFT_ALIGNMENT);
lineInfo.setBorder(new EmptyBorder(4, 6, 0, 0));
if (getResource("line.buffer.size") != null)
{
Object[] args = { new Integer(bplayer.getLineCurrentBufferSize()) };
String str = MessageFormat.format(getResource("line.buffer.size"), args);
JLabel lineBufferSizeLabel = new JLabel(str);
lineInfo.add(lineBufferSizeLabel);
}
if (getResource("help") != null)
{
lineInfo.add(Box.createRigidArea(new Dimension(0, 30)));
JLabel helpLabel = new JLabel(getResource("help"));
lineInfo.add(helpLabel);
}
add(lineInfo);
}
}
public void actionPerformed(ActionEvent ev)
{
if (bplayer != null) bplayer.setMixerName(ev.getActionCommand());
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/DevicePreference.java | Java | asf20 | 4,499 |
/*
* PreferenceItem.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javazoom.jlgui.player.amp.PlayerUI;
public abstract class PreferenceItem extends JPanel
{
protected PlayerUI player = null;
protected ResourceBundle bundle = null;
protected boolean loaded = false;
protected JFrame parent = null;
/**
* Return I18N value of a given key.
* @param key
* @return
*/
public String getResource(String key)
{
String value = null;
if (key != null)
{
try
{
value = bundle.getString(key);
}
catch (MissingResourceException e)
{
}
}
return value;
}
public void setPlayer(PlayerUI player)
{
this.player = player;
}
public JFrame getParentFrame()
{
return parent;
}
public void setParentFrame(JFrame parent)
{
this.parent = parent;
}
public abstract void loadUI();
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/PreferenceItem.java | Java | asf20 | 2,198 |
/*
* SkinPreference.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ResourceBundle;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javazoom.jlgui.player.amp.util.FileNameFilter;
import javazoom.jlgui.player.amp.util.FileSelector;
public class SkinPreference extends PreferenceItem implements ActionListener, ListSelectionListener
{
public static final String DEFAULTSKIN = "<Default Skin>";
public static final String SKINEXTENSION = "wsz";
private DefaultListModel listModel = null;
private JList skins = null;
private JTextArea info = null;
private JPanel listPane = null;
private JPanel infoPane = null;
private JPanel browsePane = null;
private JButton selectSkinDir = null;
private static SkinPreference instance = null;
private SkinPreference()
{
listModel = new DefaultListModel();
}
public static SkinPreference getInstance()
{
if (instance == null)
{
instance = new SkinPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/skin");
setBorder(new TitledBorder(getResource("title")));
File dir = null;
if (player != null)
{
dir = new File(player.getConfig().getLastSkinDir());
}
loadSkins(dir);
skins = new JList(listModel);
skins.setBorder(new EmptyBorder(1, 2, 1, 1));
skins.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
skins.setLayoutOrientation(JList.VERTICAL);
skins.setVisibleRowCount(12);
skins.addListSelectionListener(this);
JScrollPane listScroller = new JScrollPane(skins);
listScroller.setPreferredSize(new Dimension(300, 140));
listPane = new JPanel();
listPane.add(listScroller);
infoPane = new JPanel();
info = new JTextArea(4, 35);
info.setEditable(false);
info.setCursor(null);
JScrollPane infoScroller = new JScrollPane(info);
infoScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
infoScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
infoPane.add(infoScroller);
browsePane = new JPanel();
selectSkinDir = new JButton(getResource("browser.directory.button"));
selectSkinDir.addActionListener(this);
browsePane.add(selectSkinDir);
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints cnts = new GridBagConstraints();
cnts.fill = GridBagConstraints.BOTH;
cnts.gridwidth = 1;
cnts.weightx = 1.0;
cnts.weighty = 0.60;
cnts.gridx = 0;
cnts.gridy = 0;
add(listPane, cnts);
cnts.gridwidth = 1;
cnts.weightx = 1.0;
cnts.weighty = 0.30;
cnts.gridx = 0;
cnts.gridy = 1;
add(infoPane, cnts);
cnts.weightx = 1.0;
cnts.weighty = 0.10;
cnts.gridx = 0;
cnts.gridy = 2;
add(browsePane, cnts);
loaded = true;
}
}
public void actionPerformed(ActionEvent ev)
{
if (ev.getActionCommand().equalsIgnoreCase(getResource("browser.directory.button")))
{
File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.DIRECTORY, false, "", "Directories", new File(player.getConfig().getLastSkinDir()));
if ((file != null) && (file[0].isDirectory()))
{
player.getConfig().setLastSkinDir(file[0].getAbsolutePath());
loadSkins(file[0]);
}
}
}
public void valueChanged(ListSelectionEvent e)
{
if (e.getValueIsAdjusting() == false)
{
if (skins.getSelectedIndex() == -1)
{
}
else
{
String name = (String) listModel.get(skins.getSelectedIndex());
String filename = player.getConfig().getLastSkinDir() + name + "." + SKINEXTENSION;
player.getSkin().setPath(filename);
player.loadSkin();
player.getConfig().setDefaultSkin(filename);
String readme = player.getSkin().getReadme();
if (readme == null) readme = "";
info.setText(readme);
info.setCaretPosition(0);
}
}
}
private void loadSkins(File dir)
{
listModel.clear();
listModel.addElement(DEFAULTSKIN);
if ((dir != null) && (dir.exists()))
{
File[] files = dir.listFiles(new FileNameFilter(SKINEXTENSION, "Skins", false));
if ((files != null) && (files.length > 0))
{
for (int i = 0; i < files.length; i++)
{
String filename = files[i].getName();
listModel.addElement(filename.substring(0, filename.length() - 4));
}
}
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/SkinPreference.java | Java | asf20 | 7,020 |
/*
* VisualPreference.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Hashtable;
import java.util.ResourceBundle;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer;
public class VisualPreference extends PreferenceItem implements ActionListener, ChangeListener
{
private JPanel modePane = null;
private JPanel spectrumPane = null;
private JPanel oscilloPane = null;
private JRadioButton spectrumMode = null;
private JRadioButton oscilloMode = null;
private JRadioButton offMode = null;
private JCheckBox peaksBox = null;
private JSlider analyzerFalloff = null;
private JSlider peaksFalloff = null;
private static VisualPreference instance = null;
private VisualPreference()
{
}
public static VisualPreference getInstance()
{
if (instance == null)
{
instance = new VisualPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/visual");
setBorder(new TitledBorder(getResource("title")));
modePane = new JPanel();
modePane.setBorder(new TitledBorder(getResource("mode.title")));
modePane.setLayout(new FlowLayout());
spectrumMode = new JRadioButton(getResource("mode.spectrum"));
spectrumMode.addActionListener(this);
oscilloMode = new JRadioButton(getResource("mode.oscilloscope"));
oscilloMode.addActionListener(this);
offMode = new JRadioButton(getResource("mode.off"));
offMode.addActionListener(this);
SpectrumTimeAnalyzer analyzer = null;
if (player != null)
{
analyzer = player.getSkin().getAcAnalyzer();
int displayMode = SpectrumTimeAnalyzer.DISPLAY_MODE_OFF;
if (analyzer != null)
{
displayMode = analyzer.getDisplayMode();
}
if (displayMode == SpectrumTimeAnalyzer.DISPLAY_MODE_SPECTRUM_ANALYSER)
{
spectrumMode.setSelected(true);
}
else if (displayMode == SpectrumTimeAnalyzer.DISPLAY_MODE_SCOPE)
{
oscilloMode.setSelected(true);
}
else if (displayMode == SpectrumTimeAnalyzer.DISPLAY_MODE_OFF)
{
offMode.setSelected(true);
}
}
ButtonGroup modeGroup = new ButtonGroup();
modeGroup.add(spectrumMode);
modeGroup.add(oscilloMode);
modeGroup.add(offMode);
modePane.add(spectrumMode);
modePane.add(oscilloMode);
modePane.add(offMode);
spectrumPane = new JPanel();
spectrumPane.setLayout(new BoxLayout(spectrumPane, BoxLayout.Y_AXIS));
peaksBox = new JCheckBox(getResource("spectrum.peaks"));
peaksBox.setAlignmentX(Component.LEFT_ALIGNMENT);
peaksBox.addActionListener(this);
if ((analyzer != null) && (analyzer.isPeaksEnabled())) peaksBox.setSelected(true);
else peaksBox.setSelected(false);
spectrumPane.add(peaksBox);
// Analyzer falloff.
JLabel analyzerFalloffLabel = new JLabel(getResource("spectrum.analyzer.falloff"));
analyzerFalloffLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
spectrumPane.add(analyzerFalloffLabel);
int minDecay = (int) (SpectrumTimeAnalyzer.MIN_SPECTRUM_ANALYSER_DECAY * 100);
int maxDecay = (int) (SpectrumTimeAnalyzer.MAX_SPECTRUM_ANALYSER_DECAY * 100);
int decay = (maxDecay + minDecay) / 2;
if (analyzer != null)
{
decay = (int) (analyzer.getSpectrumAnalyserDecay() * 100);
}
analyzerFalloff = new JSlider(JSlider.HORIZONTAL, minDecay, maxDecay, decay);
analyzerFalloff.setMajorTickSpacing(1);
analyzerFalloff.setPaintTicks(true);
analyzerFalloff.setMaximumSize(new Dimension(150, analyzerFalloff.getPreferredSize().height));
analyzerFalloff.setAlignmentX(Component.LEFT_ALIGNMENT);
analyzerFalloff.setSnapToTicks(true);
analyzerFalloff.addChangeListener(this);
spectrumPane.add(analyzerFalloff);
// Peaks falloff.
JLabel peaksFalloffLabel = new JLabel(getResource("spectrum.peaks.falloff"));
peaksFalloffLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
spectrumPane.add(peaksFalloffLabel);
int peakDelay = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY;
int fps = SpectrumTimeAnalyzer.DEFAULT_FPS;
if (analyzer != null)
{
fps = analyzer.getFps();
peakDelay = analyzer.getPeakDelay();
}
peaksFalloff = new JSlider(JSlider.HORIZONTAL, 0, 4, computeSliderValue(peakDelay, fps));
peaksFalloff.setMajorTickSpacing(1);
peaksFalloff.setPaintTicks(true);
peaksFalloff.setSnapToTicks(true);
Hashtable labelTable = new Hashtable();
labelTable.put(new Integer(0), new JLabel("Slow"));
labelTable.put(new Integer(4), new JLabel("Fast"));
peaksFalloff.setLabelTable(labelTable);
peaksFalloff.setPaintLabels(true);
peaksFalloff.setMaximumSize(new Dimension(150, peaksFalloff.getPreferredSize().height));
peaksFalloff.setAlignmentX(Component.LEFT_ALIGNMENT);
peaksFalloff.addChangeListener(this);
spectrumPane.add(peaksFalloff);
// Spectrum pane
spectrumPane.setBorder(new TitledBorder(getResource("spectrum.title")));
if (getResource("oscilloscope.title") != null)
{
oscilloPane = new JPanel();
oscilloPane.setBorder(new TitledBorder(getResource("oscilloscope.title")));
}
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints cnts = new GridBagConstraints();
cnts.fill = GridBagConstraints.BOTH;
cnts.gridwidth = 2;
cnts.weightx = 2.0;
cnts.weighty = 0.25;
cnts.gridx = 0;
cnts.gridy = 0;
add(modePane, cnts);
cnts.gridwidth = 1;
cnts.weightx = 1.0;
cnts.weighty = 1.0;
cnts.gridx = 0;
cnts.gridy = 1;
add(spectrumPane, cnts);
cnts.weightx = 1.0;
cnts.weighty = 1.0;
cnts.gridx = 1;
cnts.gridy = 1;
if (oscilloPane != null) add(oscilloPane, cnts);
if (analyzer == null)
{
disablePane(modePane);
disablePane(spectrumPane);
disablePane(oscilloPane);
}
loaded = true;
}
}
private void disablePane(JPanel pane)
{
if (pane != null)
{
Component[] cpns = pane.getComponents();
if (cpns != null)
{
for (int i = 0; i < cpns.length; i++)
{
cpns[i].setEnabled(false);
}
}
}
}
public void actionPerformed(ActionEvent ev)
{
if (player != null)
{
SpectrumTimeAnalyzer analyzer = player.getSkin().getAcAnalyzer();
if (analyzer != null)
{
if (ev.getSource().equals(spectrumMode))
{
analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_SPECTRUM_ANALYSER);
analyzer.startDSP(null);
}
else if (ev.getSource().equals(oscilloMode))
{
analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_SCOPE);
analyzer.startDSP(null);
}
else if (ev.getSource().equals(offMode))
{
analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_OFF);
analyzer.closeDSP();
analyzer.repaint();
}
else if (ev.getSource().equals(peaksBox))
{
if (peaksBox.isSelected()) analyzer.setPeaksEnabled(true);
else analyzer.setPeaksEnabled(false);
}
}
}
}
public void stateChanged(ChangeEvent ce)
{
if (player != null)
{
SpectrumTimeAnalyzer analyzer = player.getSkin().getAcAnalyzer();
if (analyzer != null)
{
if (ce.getSource() == analyzerFalloff)
{
if (!analyzerFalloff.getValueIsAdjusting())
{
analyzer.setSpectrumAnalyserDecay(analyzerFalloff.getValue() * 1.0f / 100.0f);
}
}
else if (ce.getSource() == peaksFalloff)
{
if (!peaksFalloff.getValueIsAdjusting())
{
analyzer.setPeakDelay(computeDelay(peaksFalloff.getValue(), analyzer.getFps()));
}
}
}
}
}
private int computeDelay(int slidervalue, int fps)
{
float p = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO;
float n = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE;
int delay = Math.round(((-n * slidervalue * 1.0f / 2.0f) + p + n) * fps);
return delay;
}
private int computeSliderValue(int delay, int fps)
{
float p = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO;
float n = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE;
int value = (int) Math.round((((p - (delay * 1.0 / fps * 1.0f)) * 2 / n) + 2));
return value;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/VisualPreference.java | Java | asf20 | 12,060 |
/*
* NodeItem.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
public class NodeItem
{
private String name = null;
private String impl = null;
public NodeItem(String name, String impl)
{
super();
this.name = name;
this.impl = impl;
}
public String getImpl()
{
return impl;
}
public String toString()
{
return name;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/NodeItem.java | Java | asf20 | 1,420 |
/*
* OutputPreference.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import java.util.ResourceBundle;
import javax.swing.border.TitledBorder;
public class OutputPreference extends PreferenceItem
{
private static OutputPreference instance = null;
private OutputPreference()
{
}
public static OutputPreference getInstance()
{
if (instance == null)
{
instance = new OutputPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/output");
setBorder(new TitledBorder(getResource("title")));
loaded = true;
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/OutputPreference.java | Java | asf20 | 1,773 |
/*
* VisualizationPreference.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util.ui;
import java.util.ResourceBundle;
import javax.swing.border.TitledBorder;
public class VisualizationPreference extends PreferenceItem
{
private static VisualizationPreference instance = null;
private VisualizationPreference()
{
}
public static VisualizationPreference getInstance()
{
if (instance == null)
{
instance = new VisualizationPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/visualization");
setBorder(new TitledBorder(getResource("title")));
loaded = true;
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/util/ui/VisualizationPreference.java | Java | asf20 | 1,822 |
/*
* Cubic.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.equalizer.ui;
public class Cubic
{
float a, b, c, d; /* a + b*u + c*u^2 +d*u^3 */
public Cubic(float a, float b, float c, float d)
{
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
/**
* Evaluate cubic.
* @param u
* @return
*/
public float eval(float u)
{
return (((d * u) + c) * u + b) * u + a;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/equalizer/ui/Cubic.java | Java | asf20 | 1,462 |
/*
* EqualizerUI.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.equalizer.ui;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javazoom.jlgui.player.amp.PlayerActionEvent;
import javazoom.jlgui.player.amp.PlayerUI;
import javazoom.jlgui.player.amp.skin.AbsoluteLayout;
import javazoom.jlgui.player.amp.skin.DropTargetAdapter;
import javazoom.jlgui.player.amp.skin.ImageBorder;
import javazoom.jlgui.player.amp.skin.Skin;
import javazoom.jlgui.player.amp.util.Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class implements an equalizer UI.
* <p/>
* The equalizer consists of 32 band-pass filters.
* Each band of the equalizer can take on a fractional value between
* -1.0 and +1.0.
* At -1.0, the input signal is attenuated by 6dB, at +1.0 the signal is
* amplified by 6dB.
*/
public class EqualizerUI extends JPanel implements ActionListener, ChangeListener
{
private static Log log = LogFactory.getLog(EqualizerUI.class);
private int minGain = 0;
private int maxGain = 100;
private int[] gainValue = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 };
private int[] PRESET_NORMAL = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 };
private int[] PRESET_CLASSICAL = { 50, 50, 50, 50, 50, 50, 70, 70, 70, 76 };
private int[] PRESET_CLUB = { 50, 50, 42, 34, 34, 34, 42, 50, 50, 50 };
private int[] PRESET_DANCE = { 26, 34, 46, 50, 50, 66, 70, 70, 50, 50 };
private int[] PRESET_FULLBASS = { 26, 26, 26, 36, 46, 62, 76, 78, 78, 78 };
private int[] PRESET_FULLBASSTREBLE = { 34, 34, 50, 68, 62, 46, 28, 22, 18, 18 };
private int[] PRESET_FULLTREBLE = { 78, 78, 78, 62, 42, 24, 8, 8, 8, 8 };
private int[] PRESET_LAPTOP = { 38, 22, 36, 60, 58, 46, 38, 24, 16, 14 };
private int[] PRESET_LIVE = { 66, 50, 40, 36, 34, 34, 40, 42, 42, 42 };
private int[] PRESET_PARTY = { 32, 32, 50, 50, 50, 50, 50, 50, 32, 32 };
private int[] PRESET_POP = { 56, 38, 32, 30, 38, 54, 56, 56, 54, 54 };
private int[] PRESET_REGGAE = { 48, 48, 50, 66, 48, 34, 34, 48, 48, 48 };
private int[] PRESET_ROCK = { 32, 38, 64, 72, 56, 40, 28, 24, 24, 24 };
private int[] PRESET_TECHNO = { 30, 34, 48, 66, 64, 48, 30, 24, 24, 28 };
private Config config = null;
private PlayerUI player = null;
private Skin ui = null;
private JPopupMenu mainpopup = null;
public static final int LINEARDIST = 1;
public static final int OVERDIST = 2;
private float[] bands = null;
private int[] eqgains = null;
private int eqdist = OVERDIST;
public EqualizerUI()
{
super();
setDoubleBuffered(true);
config = Config.getInstance();
eqgains = new int[10];
setLayout(new AbsoluteLayout());
int[] vals = config.getLastEqualizer();
if (vals != null)
{
for (int h = 0; h < vals.length; h++)
{
gainValue[h] = vals[h];
}
}
// DnD support disabled.
DropTargetAdapter dnd = new DropTargetAdapter()
{
public void processDrop(Object data)
{
return;
}
};
DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, false);
}
/**
* Return skin.
* @return
*/
public Skin getSkin()
{
return ui;
}
/**
* Set skin.
* @param ui
*/
public void setSkin(Skin ui)
{
this.ui = ui;
}
/**
* Set parent player.
* @param mp
*/
public void setPlayer(PlayerUI mp)
{
player = mp;
}
public void loadUI()
{
log.info("Load EqualizerUI (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
removeAll();
// Background
ImageBorder border = new ImageBorder();
border.setImage(ui.getEqualizerImage());
setBorder(border);
// On/Off
add(ui.getAcEqOnOff(), ui.getAcEqOnOff().getConstraints());
ui.getAcEqOnOff().removeActionListener(this);
ui.getAcEqOnOff().addActionListener(this);
// Auto
add(ui.getAcEqAuto(), ui.getAcEqAuto().getConstraints());
ui.getAcEqAuto().removeActionListener(this);
ui.getAcEqAuto().addActionListener(this);
// Sliders
add(ui.getAcEqPresets(), ui.getAcEqPresets().getConstraints());
for (int i = 0; i < ui.getAcEqSliders().length; i++)
{
add(ui.getAcEqSliders()[i], ui.getAcEqSliders()[i].getConstraints());
ui.getAcEqSliders()[i].setValue(maxGain - gainValue[i]);
ui.getAcEqSliders()[i].removeChangeListener(this);
ui.getAcEqSliders()[i].addChangeListener(this);
}
if (ui.getSpline() != null)
{
ui.getSpline().setValues(gainValue);
add(ui.getSpline(), ui.getSpline().getConstraints());
}
// Popup menu on TitleBar
mainpopup = new JPopupMenu();
String[] presets = { "Normal", "Classical", "Club", "Dance", "Full Bass", "Full Bass & Treble", "Full Treble", "Laptop", "Live", "Party", "Pop", "Reggae", "Rock", "Techno" };
JMenuItem mi;
for (int p = 0; p < presets.length; p++)
{
mi = new JMenuItem(presets[p]);
mi.removeActionListener(this);
mi.addActionListener(this);
mainpopup.add(mi);
}
ui.getAcEqPresets().removeActionListener(this);
ui.getAcEqPresets().addActionListener(this);
validate();
}
/* (non-Javadoc)
* @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
*/
public void stateChanged(ChangeEvent e)
{
for (int i = 0; i < ui.getAcEqSliders().length; i++)
{
gainValue[i] = maxGain - ui.getAcEqSliders()[i].getValue();
}
if (ui.getSpline() != null) ui.getSpline().repaint();
// Apply equalizer values.
synchronizeEqualizer();
}
/**
* Set bands array for equalizer.
*
* @param bands
*/
public void setBands(float[] bands)
{
this.bands = bands;
}
/**
* Apply equalizer function.
*
* @param gains
* @param min
* @param max
*/
public void updateBands(int[] gains, int min, int max)
{
if ((gains != null) && (bands != null))
{
int j = 0;
float gvalj = (gains[j] * 2.0f / (max - min) * 1.0f) - 1.0f;
float gvalj1 = (gains[j + 1] * 2.0f / (max - min) * 1.0f) - 1.0f;
// Linear distribution : 10 values => 32 values.
if (eqdist == LINEARDIST)
{
float a = (gvalj1 - gvalj) * 1.0f;
float b = gvalj * 1.0f - (gvalj1 - gvalj) * j;
// x=s*x'
float s = (gains.length - 1) * 1.0f / (bands.length - 1) * 1.0f;
for (int i = 0; i < bands.length; i++)
{
float ind = s * i;
if (ind > (j + 1))
{
j++;
gvalj = (gains[j] * 2.0f / (max - min) * 1.0f) - 1.0f;
gvalj1 = (gains[j + 1] * 2.0f / (max - min) * 1.0f) - 1.0f;
a = (gvalj1 - gvalj) * 1.0f;
b = gvalj * 1.0f - (gvalj1 - gvalj) * j;
}
// a*x+b
bands[i] = a * i * 1.0f * s + b;
}
}
// Over distribution : 10 values => 10 first value of 32 values.
else if (eqdist == OVERDIST)
{
for (int i = 0; i < gains.length; i++)
{
bands[i] = (gains[i] * 2.0f / (max - min) * 1.0f) - 1.0f;
}
}
}
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
// On/Off
if (cmd.equals(PlayerActionEvent.ACEQONOFF))
{
if (ui.getAcEqOnOff().isSelected())
{
config.setEqualizerOn(true);
}
else
{
config.setEqualizerOn(false);
}
synchronizeEqualizer();
}
// Auto
else if (cmd.equals(PlayerActionEvent.ACEQAUTO))
{
if (ui.getAcEqAuto().isSelected())
{
config.setEqualizerAuto(true);
}
else
{
config.setEqualizerAuto(false);
}
}
// Presets
else if (cmd.equals(PlayerActionEvent.ACEQPRESETS))
{
if (e.getModifiers() == MouseEvent.BUTTON1_MASK)
{
mainpopup.show(this, ui.getAcEqPresets().getLocation().x, ui.getAcEqPresets().getLocation().y);
}
}
else if (cmd.equals("Normal"))
{
updateSliders(PRESET_NORMAL);
synchronizeEqualizer();
}
else if (cmd.equals("Classical"))
{
updateSliders(PRESET_CLASSICAL);
synchronizeEqualizer();
}
else if (cmd.equals("Club"))
{
updateSliders(PRESET_CLUB);
synchronizeEqualizer();
}
else if (cmd.equals("Dance"))
{
updateSliders(PRESET_DANCE);
synchronizeEqualizer();
}
else if (cmd.equals("Full Bass"))
{
updateSliders(PRESET_FULLBASS);
synchronizeEqualizer();
}
else if (cmd.equals("Full Bass & Treble"))
{
updateSliders(PRESET_FULLBASSTREBLE);
synchronizeEqualizer();
}
else if (cmd.equals("Full Treble"))
{
updateSliders(PRESET_FULLTREBLE);
synchronizeEqualizer();
}
else if (cmd.equals("Laptop"))
{
updateSliders(PRESET_LAPTOP);
synchronizeEqualizer();
}
else if (cmd.equals("Live"))
{
updateSliders(PRESET_LIVE);
synchronizeEqualizer();
}
else if (cmd.equals("Party"))
{
updateSliders(PRESET_PARTY);
synchronizeEqualizer();
}
else if (cmd.equals("Pop"))
{
updateSliders(PRESET_POP);
synchronizeEqualizer();
}
else if (cmd.equals("Reggae"))
{
updateSliders(PRESET_REGGAE);
synchronizeEqualizer();
}
else if (cmd.equals("Rock"))
{
updateSliders(PRESET_ROCK);
synchronizeEqualizer();
}
else if (cmd.equals("Techno"))
{
updateSliders(PRESET_TECHNO);
synchronizeEqualizer();
}
}
/**
* Update sliders from gains array.
*
* @param gains
*/
public void updateSliders(int[] gains)
{
if (gains != null)
{
for (int i = 0; i < gains.length; i++)
{
gainValue[i + 1] = gains[i];
ui.getAcEqSliders()[i + 1].setValue(maxGain - gainValue[i + 1]);
}
}
}
/**
* Apply equalizer values.
*/
public void synchronizeEqualizer()
{
config.setLastEqualizer(gainValue);
if (config.isEqualizerOn())
{
for (int j = 0; j < eqgains.length; j++)
{
eqgains[j] = -gainValue[j + 1] + maxGain;
}
updateBands(eqgains, minGain, maxGain);
}
else
{
for (int j = 0; j < eqgains.length; j++)
{
eqgains[j] = (maxGain - minGain) / 2;
}
updateBands(eqgains, minGain, maxGain);
}
}
/**
* Return equalizer bands distribution.
* @return
*/
public int getEqdist()
{
return eqdist;
}
/**
* Set equalizer bands distribution.
* @param i
*/
public void setEqdist(int i)
{
eqdist = i;
}
/**
* Simulates "On/Off" selection.
*/
public void pressOnOff()
{
ui.getAcEqOnOff().doClick();
}
/**
* Simulates "Auto" selection.
*/
public void pressAuto()
{
ui.getAcEqAuto().doClick();
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/equalizer/ui/EqualizerUI.java | Java | asf20 | 14,333 |
/*
* NaturalSpline.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.equalizer.ui;
import java.awt.Polygon;
public class NaturalSpline extends ControlCurve
{
public final int STEPS = 12;
public NaturalSpline()
{
super();
}
/*
* calculates the natural cubic spline that interpolates y[0], y[1], ...
* y[n] The first segment is returned as C[0].a + C[0].b*u + C[0].c*u^2 +
* C[0].d*u^3 0<=u <1 the other segments are in C[1], C[2], ... C[n-1]
*/
Cubic[] calcNaturalCubic(int n, int[] x)
{
float[] gamma = new float[n + 1];
float[] delta = new float[n + 1];
float[] D = new float[n + 1];
int i;
/*
* We solve the equation [2 1 ] [D[0]] [3(x[1] - x[0]) ] |1 4 1 | |D[1]|
* |3(x[2] - x[0]) | | 1 4 1 | | . | = | . | | ..... | | . | | . | | 1 4
* 1| | . | |3(x[n] - x[n-2])| [ 1 2] [D[n]] [3(x[n] - x[n-1])]
*
* by using row operations to convert the matrix to upper triangular and
* then back sustitution. The D[i] are the derivatives at the knots.
*/
gamma[0] = 1.0f / 2.0f;
for (i = 1; i < n; i++)
{
gamma[i] = 1 / (4 - gamma[i - 1]);
}
gamma[n] = 1 / (2 - gamma[n - 1]);
delta[0] = 3 * (x[1] - x[0]) * gamma[0];
for (i = 1; i < n; i++)
{
delta[i] = (3 * (x[i + 1] - x[i - 1]) - delta[i - 1]) * gamma[i];
}
delta[n] = (3 * (x[n] - x[n - 1]) - delta[n - 1]) * gamma[n];
D[n] = delta[n];
for (i = n - 1; i >= 0; i--)
{
D[i] = delta[i] - gamma[i] * D[i + 1];
}
/* now compute the coefficients of the cubics */
Cubic[] C = new Cubic[n];
for (i = 0; i < n; i++)
{
C[i] = new Cubic((float) x[i], D[i], 3 * (x[i + 1] - x[i]) - 2 * D[i] - D[i + 1], 2 * (x[i] - x[i + 1]) + D[i] + D[i + 1]);
}
return C;
}
/**
* Return a cubic spline.
*/
public Polygon getPolyline()
{
Polygon p = new Polygon();
if (pts.npoints >= 2)
{
Cubic[] X = calcNaturalCubic(pts.npoints - 1, pts.xpoints);
Cubic[] Y = calcNaturalCubic(pts.npoints - 1, pts.ypoints);
// very crude technique - just break each segment up into steps lines
int x = (int) Math.round(X[0].eval(0));
int y = (int) Math.round(Y[0].eval(0));
p.addPoint(x, boundY(y));
for (int i = 0; i < X.length; i++)
{
for (int j = 1; j <= STEPS; j++)
{
float u = j / (float) STEPS;
x = Math.round(X[i].eval(u));
y = Math.round(Y[i].eval(u));
p.addPoint(x, boundY(y));
}
}
}
return p;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/equalizer/ui/NaturalSpline.java | Java | asf20 | 3,961 |
/*
* SplinePanel.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.equalizer.ui;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Polygon;
import javax.swing.JPanel;
import javazoom.jlgui.player.amp.skin.AbsoluteConstraints;
public class SplinePanel extends JPanel
{
private AbsoluteConstraints constraints = null;
private Image backgroundImage = null;
private Image barImage = null;
private int[] values = null;
private Color[] gradient = null;
public SplinePanel()
{
super();
setDoubleBuffered(true);
setLayout(null);
}
public Color[] getGradient()
{
return gradient;
}
public void setGradient(Color[] gradient)
{
this.gradient = gradient;
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
public Image getBarImage()
{
return barImage;
}
public void setBarImage(Image barImage)
{
this.barImage = barImage;
}
public Image getBackgroundImage()
{
return backgroundImage;
}
public void setBackgroundImage(Image backgroundImage)
{
this.backgroundImage = backgroundImage;
}
public int[] getValues()
{
return values;
}
public void setValues(int[] values)
{
this.values = values;
}
/* (non-Javadoc)
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
public void paintComponent(Graphics g)
{
if (backgroundImage != null) g.drawImage(backgroundImage, 0, 0, null);
if (barImage != null) g.drawImage(barImage, 0, getHeight()/2, null);
if ((values != null) && (values.length > 0))
{
NaturalSpline curve = new NaturalSpline();
float dx = 1.0f * getWidth() / (values.length - 2);
int h = getHeight();
curve.setMaxHeight(h);
curve.setMinHeight(0);
for (int i = 1; i < values.length; i++)
{
int x1 = (int) Math.round(dx * (i - 1));
int y1 = ((int) Math.round((h * values[i] / 100)));
y1 = curve.boundY(y1);
curve.addPoint(x1, y1);
}
Polygon spline = curve.getPolyline();
if (gradient != null)
{
for (int i=0;i<(spline.npoints-1);i++)
{
g.setColor(gradient[spline.ypoints[i]]);
g.drawLine(spline.xpoints[i], spline.ypoints[i],spline.xpoints[i+1], spline.ypoints[i+1]);
}
}
else
{
g.drawPolyline(spline.xpoints, spline.ypoints, spline.npoints);
}
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/equalizer/ui/SplinePanel.java | Java | asf20 | 3,981 |
/*
* ControlCurve.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.equalizer.ui;
import java.awt.Polygon;
public abstract class ControlCurve
{
static final int EPSILON = 36; /* square of distance for picking */
protected Polygon pts;
protected int selection = -1;
int maxHeight = -1;
int minHeight = -1;
public ControlCurve()
{
pts = new Polygon();
}
public int boundY(int y)
{
int ny = y;
if ((minHeight >= 0) && (y < minHeight))
{
ny = 0;
}
if ((maxHeight >= 0) && (y >= maxHeight))
{
ny = maxHeight - 1;
}
return ny;
}
public void setMaxHeight(int h)
{
maxHeight = h;
}
public void setMinHeight(int h)
{
minHeight = h;
}
/**
* Return index of control point near to (x,y) or -1 if nothing near.
* @param x
* @param y
* @return
*/
public int selectPoint(int x, int y)
{
int mind = Integer.MAX_VALUE;
selection = -1;
for (int i = 0; i < pts.npoints; i++)
{
int d = sqr(pts.xpoints[i] - x) + sqr(pts.ypoints[i] - y);
if (d < mind && d < EPSILON)
{
mind = d;
selection = i;
}
}
return selection;
}
/**
* Square of an int.
* @param x
* @return
*/
static int sqr(int x)
{
return x * x;
}
/**
* Add a control point, return index of new control point.
* @param x
* @param y
* @return
*/
public int addPoint(int x, int y)
{
pts.addPoint(x, y);
return selection = pts.npoints - 1;
}
/**
* Set selected control point.
* @param x
* @param y
*/
public void setPoint(int x, int y)
{
if (selection >= 0)
{
pts.xpoints[selection] = x;
pts.ypoints[selection] = y;
}
}
/**
* Remove selected control point.
*/
public void removePoint()
{
if (selection >= 0)
{
pts.npoints--;
for (int i = selection; i < pts.npoints; i++)
{
pts.xpoints[i] = pts.xpoints[i + 1];
pts.ypoints[i] = pts.ypoints[i + 1];
}
}
}
public abstract Polygon getPolyline();
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/equalizer/ui/ControlCurve.java | Java | asf20 | 3,505 |
/*
* 21.04.2004 Original verion. davagin@udm.ru.
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag;
import org.tritonus.share.sampled.TAudioFormat;
import org.tritonus.share.sampled.file.TAudioFileFormat;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.Vector;
/**
* This class gives information (audio format and comments) about APE file or URL.
*/
public class APEInfo implements TagInfo
{
protected int channels = -1;
protected int bitspersample = -1;
protected int samplerate = -1;
protected int bitrate = -1;
protected int version = -1;
protected String compressionlevel = null;
protected int totalframes = -1;
protected int blocksperframe = -1;
protected int finalframeblocks = -1;
protected int totalblocks = -1;
protected int peaklevel = -1;
protected long duration = -1;
protected String author = null;
protected String title = null;
protected String copyright = null;
protected Date date = null;
protected String comment = null;
protected String track = null;
protected String genre = null;
protected String album = null;
protected long size = 0;
protected String location = null;
/**
* Constructor.
*/
public APEInfo()
{
super();
}
/**
* Load and parse APE info from File.
*
* @param input
* @throws IOException
*/
public void load(File input) throws IOException, UnsupportedAudioFileException
{
size = input.length();
location = input.getPath();
loadInfo(input);
}
/**
* Load and parse APE info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(URL input) throws IOException, UnsupportedAudioFileException
{
location = input.toString();
loadInfo(input);
}
/**
* Load and parse APE info from InputStream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(InputStream input) throws IOException, UnsupportedAudioFileException
{
loadInfo(input);
}
/**
* Load APE info from input stream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
/**
* Load APE info from file.
*
* @param file
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
loadInfo(aff);
}
/**
* Load APE info from AudioFileFormat.
*
* @param aff
*/
protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException
{
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("Monkey's Audio (ape)") && !type.equalsIgnoreCase("Monkey's Audio (mac)")) throw new UnsupportedAudioFileException("Not APE audio format");
if (aff instanceof TAudioFileFormat)
{
Map props = ((TAudioFileFormat) aff).properties();
if (props.containsKey("duration")) duration = ((Long) props.get("duration")).longValue();
if (props.containsKey("author")) author = (String) props.get("author");
if (props.containsKey("title")) title = (String) props.get("title");
if (props.containsKey("copyright")) copyright = (String) props.get("copyright");
if (props.containsKey("date")) date = (Date) props.get("date");
if (props.containsKey("comment")) comment = (String) props.get("comment");
if (props.containsKey("album")) album = (String) props.get("album");
if (props.containsKey("track")) track = (String) props.get("track");
if (props.containsKey("genre")) genre = (String) props.get("genre");
AudioFormat af = aff.getFormat();
channels = af.getChannels();
samplerate = (int) af.getSampleRate();
bitspersample = af.getSampleSizeInBits();
if (af instanceof TAudioFormat)
{
props = ((TAudioFormat) af).properties();
if (props.containsKey("bitrate")) bitrate = ((Integer) props.get("bitrate")).intValue();
if (props.containsKey("ape.version")) version = ((Integer) props.get("ape.version")).intValue();
if (props.containsKey("ape.compressionlevel"))
{
int cl = ((Integer) props.get("ape.compressionlevel")).intValue();
switch (cl)
{
case 1000:
compressionlevel = "Fast";
break;
case 2000:
compressionlevel = "Normal";
break;
case 3000:
compressionlevel = "High";
break;
case 4000:
compressionlevel = "Extra High";
break;
case 5000:
compressionlevel = "Insane";
break;
}
}
if (props.containsKey("ape.totalframes")) totalframes = ((Integer) props.get("ape.totalframes")).intValue();
if (props.containsKey("ape.blocksperframe")) totalframes = ((Integer) props.get("ape.blocksperframe")).intValue();
if (props.containsKey("ape.finalframeblocks")) finalframeblocks = ((Integer) props.get("ape.finalframeblocks")).intValue();
if (props.containsKey("ape.totalblocks")) totalblocks = ((Integer) props.get("ape.totalblocks")).intValue();
if (props.containsKey("ape.peaklevel")) peaklevel = ((Integer) props.get("ape.peaklevel")).intValue();
}
}
}
/**
* Load APE info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
public long getSize()
{
return size;
}
public String getLocation()
{
return location;
}
public int getVersion()
{
return version;
}
public String getCompressionlevel()
{
return compressionlevel;
}
public int getTotalframes()
{
return totalframes;
}
public int getBlocksperframe()
{
return blocksperframe;
}
public int getFinalframeblocks()
{
return finalframeblocks;
}
public int getChannels()
{
return channels;
}
public int getSamplingRate()
{
return samplerate;
}
public int getBitsPerSample()
{
return bitspersample;
}
public int getTotalblocks()
{
return totalblocks;
}
public long getPlayTime()
{
return duration / 1000;
}
public int getBitRate()
{
return bitrate * 1000;
}
public int getPeaklevel()
{
return peaklevel;
}
public int getTrack()
{
int t;
try
{
t = Integer.parseInt(track);
}
catch (Exception e)
{
t = -1;
}
return t;
}
public String getYear()
{
if (date != null)
{
Calendar c = Calendar.getInstance();
c.setTime(date);
return String.valueOf(c.get(Calendar.YEAR));
}
return null;
}
public String getGenre()
{
return genre;
}
public String getTitle()
{
return title;
}
public String getArtist()
{
return author;
}
public String getAlbum()
{
return album;
}
public Vector getComment()
{
if (comment != null)
{
Vector c = new Vector();
c.add(comment);
return c;
}
return null;
}
public String getCopyright()
{
return copyright;
}
} | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/APEInfo.java | Java | asf20 | 10,107 |
/*
* TagInfo.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Vector;
import javax.sound.sampled.UnsupportedAudioFileException;
/**
* This interface define needed features for song information.
* Adapted from Scott Pennell interface.
*/
public interface TagInfo
{
public void load(InputStream input) throws IOException, UnsupportedAudioFileException;
public void load(URL input) throws IOException, UnsupportedAudioFileException;
public void load(File input) throws IOException, UnsupportedAudioFileException;
/**
* Get Sampling Rate
*
* @return sampling rate
*/
public int getSamplingRate();
/**
* Get Nominal Bitrate
*
* @return bitrate in bps
*/
public int getBitRate();
/**
* Get channels.
*
* @return channels
*/
public int getChannels();
/**
* Get play time in seconds.
*
* @return play time in seconds
*/
public long getPlayTime();
/**
* Get the title of the song.
*
* @return the title of the song
*/
public String getTitle();
/**
* Get the artist that performed the song
*
* @return the artist that performed the song
*/
public String getArtist();
/**
* Get the name of the album upon which the song resides
*
* @return the album name
*/
public String getAlbum();
/**
* Get the track number of this track on the album
*
* @return the track number
*/
public int getTrack();
/**
* Get the genre string of the music
*
* @return the genre string
*/
public String getGenre();
/**
* Get the year the track was released
*
* @return the year the track was released
*/
public String getYear();
/**
* Get any comments provided about the song
*
* @return the comments
*/
public Vector getComment();
} | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/TagInfo.java | Java | asf20 | 3,016 |
/*
* 21.04.2004 Original verion. davagin@udm.ru.
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Vector;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
/**
* This class gives information (audio format and comments) about Flac file or URL.
*/
public class FlacInfo implements TagInfo {
protected int channels = -1;
protected int bitspersample = -1;
protected int samplerate = -1;
protected long size = 0;
protected String location = null;
/**
* Constructor.
*/
public FlacInfo() {
super();
}
/**
* Load and parse Flac info from File.
*
* @param input
* @throws IOException
*/
public void load(File input) throws IOException, UnsupportedAudioFileException {
size = input.length();
location = input.getPath();
loadInfo(input);
}
/**
* Load and parse Flac info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(URL input) throws IOException, UnsupportedAudioFileException {
location = input.toString();
loadInfo(input);
}
/**
* Load and parse Flac info from InputStream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(InputStream input) throws IOException, UnsupportedAudioFileException {
loadInfo(input);
}
/**
* Load Flac info from input stream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
/**
* Load Flac info from file.
*
* @param file
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
loadInfo(aff);
}
/**
* Load Flac info from AudioFileFormat.
*
* @param aff
*/
protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException {
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("flac")) throw new UnsupportedAudioFileException("Not Flac audio format");
AudioFormat af = aff.getFormat();
channels = af.getChannels();
samplerate = (int) af.getSampleRate();
bitspersample = af.getSampleSizeInBits();
}
/**
* Load Flac info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
public long getSize() {
return size;
}
public String getLocation() {
return location;
}
public int getChannels() {
return channels;
}
public int getSamplingRate() {
return samplerate;
}
public int getBitsPerSample() {
return bitspersample;
}
public Vector getComment() {
return null;
}
public String getYear() {
return null;
}
public String getGenre() {
return null;
}
public int getTrack() {
return -1;
}
public String getAlbum() {
return null;
}
public String getArtist() {
return null;
}
public String getTitle() {
return null;
}
public long getPlayTime() {
return -1;
}
public int getBitRate() {
return -1;
}
} | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/FlacInfo.java | Java | asf20 | 5,126 |
/*
* MpegInfo.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag;
import org.tritonus.share.sampled.file.TAudioFileFormat;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
/**
* This class gives information (audio format and comments) about MPEG file or URL.
*/
public class MpegInfo implements TagInfo {
protected int channels = -1;
protected String channelsMode = null;
protected String version = null;
protected int rate = 0;
protected String layer = null;
protected String emphasis = null;
protected int nominalbitrate = 0;
protected long total = 0;
protected String vendor = null;
protected String location = null;
protected long size = 0;
protected boolean copyright = false;
protected boolean crc = false;
protected boolean original = false;
protected boolean priv = false;
protected boolean vbr = false;
protected int track = -1;
protected String year = null;
protected String genre = null;
protected String title = null;
protected String artist = null;
protected String album = null;
protected Vector comments = null;
/**
* Constructor.
*/
public MpegInfo() {
super();
}
/**
* Load and parse MPEG info from File.
*
* @param input
* @throws IOException
*/
public void load(File input) throws IOException, UnsupportedAudioFileException {
size = input.length();
location = input.getPath();
loadInfo(input);
}
/**
* Load and parse MPEG info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(URL input) throws IOException, UnsupportedAudioFileException {
location = input.toString();
loadInfo(input);
}
/**
* Load and parse MPEG info from InputStream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(InputStream input) throws IOException, UnsupportedAudioFileException {
loadInfo(input);
}
/**
* Load info from input stream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
/**
* Load MP3 info from file.
*
* @param file
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
loadInfo(aff);
}
/**
* Load info from AudioFileFormat.
*
* @param aff
*/
protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException {
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("mp3")) throw new UnsupportedAudioFileException("Not MP3 audio format");
if (aff instanceof TAudioFileFormat) {
Map props = ((TAudioFileFormat) aff).properties();
if (props.containsKey("mp3.channels")) channels = ((Integer) props.get("mp3.channels")).intValue();
if (props.containsKey("mp3.frequency.hz")) rate = ((Integer) props.get("mp3.frequency.hz")).intValue();
if (props.containsKey("mp3.bitrate.nominal.bps")) nominalbitrate = ((Integer) props.get("mp3.bitrate.nominal.bps")).intValue();
if (props.containsKey("mp3.version.layer")) layer = "Layer " + props.get("mp3.version.layer");
if (props.containsKey("mp3.version.mpeg")) {
version = (String) props.get("mp3.version.mpeg");
if (version.equals("1")) version = "MPEG1";
else if (version.equals("2")) version = "MPEG2-LSF";
else if (version.equals("2.5")) version = "MPEG2.5-LSF";
}
if (props.containsKey("mp3.mode")) {
int mode = ((Integer) props.get("mp3.mode")).intValue();
if (mode == 0) channelsMode = "Stereo";
else if (mode == 1) channelsMode = "Joint Stereo";
else if (mode == 2) channelsMode = "Dual Channel";
else if (mode == 3) channelsMode = "Single Channel";
}
if (props.containsKey("mp3.crc")) crc = ((Boolean) props.get("mp3.crc")).booleanValue();
if (props.containsKey("mp3.vbr")) vbr = ((Boolean) props.get("mp3.vbr")).booleanValue();
if (props.containsKey("mp3.copyright")) copyright = ((Boolean) props.get("mp3.copyright")).booleanValue();
if (props.containsKey("mp3.original")) original = ((Boolean) props.get("mp3.original")).booleanValue();
emphasis = "none";
if (props.containsKey("title")) title = (String) props.get("title");
if (props.containsKey("author")) artist = (String) props.get("author");
if (props.containsKey("album")) album = (String) props.get("album");
if (props.containsKey("date")) year = (String) props.get("date");
if (props.containsKey("duration")) total = (long) Math.round((((Long) props.get("duration")).longValue()) / 1000000);
if (props.containsKey("mp3.id3tag.genre")) genre = (String) props.get("mp3.id3tag.genre");
if (props.containsKey("mp3.id3tag.track")) {
try {
track = Integer.parseInt((String) props.get("mp3.id3tag.track"));
}
catch (NumberFormatException e1) {
// Not a number
}
}
}
}
/**
* Load MP3 info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
loadShoutastInfo(aff);
}
/**
* Load Shoutcast info from AudioFileFormat.
*
* @param aff
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadShoutastInfo(AudioFileFormat aff) throws IOException, UnsupportedAudioFileException {
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("mp3")) throw new UnsupportedAudioFileException("Not MP3 audio format");
if (aff instanceof TAudioFileFormat) {
Map props = ((TAudioFileFormat) aff).properties();
// Try shoutcast meta data (if any).
Iterator it = props.keySet().iterator();
comments = new Vector();
while (it.hasNext()) {
String key = (String) it.next();
if (key.startsWith("mp3.shoutcast.metadata.")) {
String value = (String) props.get(key);
key = key.substring(23, key.length());
if (key.equalsIgnoreCase("icy-name")) {
title = value;
} else if (key.equalsIgnoreCase("icy-genre")) {
genre = value;
} else {
comments.add(key + "=" + value);
}
}
}
}
}
public boolean getVBR() {
return vbr;
}
public int getChannels() {
return channels;
}
public String getVersion() {
return version;
}
public String getEmphasis() {
return emphasis;
}
public boolean getCopyright() {
return copyright;
}
public boolean getCRC() {
return crc;
}
public boolean getOriginal() {
return original;
}
public String getLayer() {
return layer;
}
public long getSize() {
return size;
}
public String getLocation() {
return location;
}
/*-- TagInfo Implementation --*/
public int getSamplingRate() {
return rate;
}
public int getBitRate() {
return nominalbitrate;
}
public long getPlayTime() {
return total;
}
public String getTitle() {
return title;
}
public String getArtist() {
return artist;
}
public String getAlbum() {
return album;
}
public int getTrack() {
return track;
}
public String getGenre() {
return genre;
}
public Vector getComment() {
return comments;
}
public String getYear() {
return year;
}
/**
* Get channels mode.
*
* @return channels mode
*/
public String getChannelsMode() {
return channelsMode;
}
} | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/MpegInfo.java | Java | asf20 | 10,419 |
/*
* TagInfoFactory.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
import javax.sound.sampled.UnsupportedAudioFileException;
import javazoom.jlgui.player.amp.tag.ui.APEDialog;
import javazoom.jlgui.player.amp.tag.ui.EmptyDialog;
import javazoom.jlgui.player.amp.tag.ui.FlacDialog;
import javazoom.jlgui.player.amp.tag.ui.MpegDialog;
import javazoom.jlgui.player.amp.tag.ui.OggVorbisDialog;
import javazoom.jlgui.player.amp.tag.ui.TagInfoDialog;
import javazoom.jlgui.player.amp.util.Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class is a factory for TagInfo and TagInfoDialog.
* It allows to any plug custom TagIngfo parser matching to TagInfo
* interface.
*/
public class TagInfoFactory
{
private static Log log = LogFactory.getLog(TagInfoFactory.class);
private static TagInfoFactory instance = null;
private Class MpegTagInfoClass = null;
private Class VorbisTagInfoClass = null;
private Class APETagInfoClass = null;
private Class FlacTagInfoClass = null;
private Config conf = null;
private TagInfoFactory()
{
super();
conf = Config.getInstance();
String classname = conf.getMpegTagInfoClassName();
MpegTagInfoClass = getTagInfoImpl(classname);
if (MpegTagInfoClass == null)
{
log.error("Error : TagInfo implementation not found in " + classname + " hierarchy");
MpegTagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.MpegInfo");
}
classname = conf.getOggVorbisTagInfoClassName();
VorbisTagInfoClass = getTagInfoImpl(classname);
if (VorbisTagInfoClass == null)
{
log.error("Error : TagInfo implementation not found in " + classname + " hierarchy");
VorbisTagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.OggVorbisInfo");
}
classname = conf.getAPETagInfoClassName();
APETagInfoClass = getTagInfoImpl(classname);
if (APETagInfoClass == null)
{
log.error("Error : TagInfo implementation not found in " + classname + " hierarchy");
APETagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.APEInfo");
}
classname = conf.getFlacTagInfoClassName();
FlacTagInfoClass = getTagInfoImpl(classname);
if (FlacTagInfoClass == null)
{
log.error("Error : TagInfo implementation not found in " + classname + " hierarchy");
FlacTagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.FlacInfo");
}
}
public static synchronized TagInfoFactory getInstance()
{
if (instance == null)
{
instance = new TagInfoFactory();
}
return instance;
}
/**
* Return tag info from a given URL.
*
* @param location
* @return TagInfo structure for given URL
*/
public TagInfo getTagInfo(URL location)
{
TagInfo taginfo;
try
{
taginfo = getTagInfoImplInstance(MpegTagInfoClass);
taginfo.load(location);
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
catch (UnsupportedAudioFileException ex)
{
// Not Mpeg Format
taginfo = null;
}
if (taginfo == null)
{
// Check Ogg Vorbis format.
try
{
taginfo = getTagInfoImplInstance(VorbisTagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not Ogg Vorbis Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
if (taginfo == null)
{
// Check APE format.
try
{
taginfo = getTagInfoImplInstance(APETagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not APE Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
if (taginfo == null)
{
// Check Flac format.
try
{
taginfo = getTagInfoImplInstance(FlacTagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not Flac Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
return taginfo;
}
/**
* Return tag info from a given String.
*
* @param location
* @return TagInfo structure for given location
*/
public TagInfo getTagInfo(String location)
{
if (Config.startWithProtocol(location))
{
try
{
return getTagInfo(new URL(location));
}
catch (MalformedURLException e)
{
return null;
}
}
else
{
return getTagInfo(new File(location));
}
}
/**
* Get TagInfo for given file.
*
* @param location
* @return TagInfo structure for given location
*/
public TagInfo getTagInfo(File location)
{
TagInfo taginfo;
// Check Mpeg format.
try
{
taginfo = getTagInfoImplInstance(MpegTagInfoClass);
taginfo.load(location);
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
catch (UnsupportedAudioFileException ex)
{
// Not Mpeg Format
taginfo = null;
}
if (taginfo == null)
{
// Check Ogg Vorbis format.
try
{
//taginfo = new OggVorbisInfo(location);
taginfo = getTagInfoImplInstance(VorbisTagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not Ogg Vorbis Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
if (taginfo == null)
{
// Check APE format.
try
{
taginfo = getTagInfoImplInstance(APETagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not APE Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
if (taginfo == null)
{
// Check Flac format.
try
{
taginfo = getTagInfoImplInstance(FlacTagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not Flac Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
return taginfo;
}
/**
* Return dialog (graphical) to display tag info.
*
* @param taginfo
* @return TagInfoDialog for given TagInfo
*/
public TagInfoDialog getTagInfoDialog(TagInfo taginfo)
{
TagInfoDialog dialog;
if (taginfo != null)
{
if (taginfo instanceof OggVorbisInfo)
{
dialog = new OggVorbisDialog(conf.getTopParent(), "OggVorbis info", (OggVorbisInfo) taginfo);
}
else if (taginfo instanceof MpegInfo)
{
dialog = new MpegDialog(conf.getTopParent(), "Mpeg info", (MpegInfo) taginfo);
}
else if (taginfo instanceof APEInfo)
{
dialog = new APEDialog(conf.getTopParent(), "Ape info", (APEInfo) taginfo);
}
else if (taginfo instanceof FlacInfo)
{
dialog = new FlacDialog(conf.getTopParent(), "Flac info", (FlacInfo) taginfo);
}
else
{
dialog = new EmptyDialog(conf.getTopParent(), "No info", taginfo);
}
}
else
{
dialog = new EmptyDialog(conf.getTopParent(), "No info", null);
}
return dialog;
}
/**
* Load and check class implementation from classname.
*
* @param classname
* @return TagInfo implementation for given class name
*/
public Class getTagInfoImpl(String classname)
{
Class aClass = null;
boolean interfaceFound = false;
if (classname != null)
{
try
{
aClass = Class.forName(classname);
Class superClass = aClass;
// Looking for TagInfo interface implementation.
while (superClass != null)
{
Class[] interfaces = superClass.getInterfaces();
for (int i = 0; i < interfaces.length; i++)
{
if ((interfaces[i].getName()).equals("javazoom.jlgui.player.amp.tag.TagInfo"))
{
interfaceFound = true;
break;
}
}
if (interfaceFound) break;
superClass = superClass.getSuperclass();
}
if (interfaceFound) log.info(classname + " loaded");
else log.info(classname + " not loaded");
}
catch (ClassNotFoundException e)
{
log.error("Error : " + classname + " : " + e.getMessage());
}
}
return aClass;
}
/**
* Return new instance of given class.
*
* @param aClass
* @return TagInfo for given class
*/
public TagInfo getTagInfoImplInstance(Class aClass)
{
TagInfo instance = null;
if (aClass != null)
{
try
{
Class[] argsClass = new Class[] {};
Constructor c = aClass.getConstructor(argsClass);
instance = (TagInfo) (c.newInstance(null));
}
catch (Exception e)
{
log.error("Cannot Instanciate : " + aClass.getName() + " : " + e.getMessage());
}
}
return instance;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/TagInfoFactory.java | Java | asf20 | 12,630 |
/*
* OggVorbisInfo.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag;
import org.tritonus.share.sampled.file.TAudioFileFormat;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Map;
import java.util.Vector;
/**
* This class gives information (audio format and comments) about Ogg Vorbis file or URL.
*/
public class OggVorbisInfo implements TagInfo
{
protected int serial = 0;
protected int channels = 0;
protected int version = 0;
protected int rate = 0;
protected int minbitrate = 0;
protected int maxbitrate = 0;
protected int averagebitrate = 0;
protected int nominalbitrate = 0;
protected long totalms = 0;
protected String vendor = "";
protected String location = null;
protected long size = 0;
protected int track = -1;
protected String year = null;
protected String genre = null;
protected String title = null;
protected String artist = null;
protected String album = null;
protected Vector comments = new Vector();
/**
* Constructor.
*/
public OggVorbisInfo()
{
super();
}
/**
* Load and parse Ogg Vorbis info from File.
*
* @param input
* @throws IOException
*/
public void load(File input) throws IOException, UnsupportedAudioFileException
{
size = input.length();
location = input.getPath();
loadInfo(input);
}
/**
* Load and parse Ogg Vorbis info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(URL input) throws IOException, UnsupportedAudioFileException
{
location = input.toString();
loadInfo(input);
}
/**
* Load and parse Ogg Vorbis info from InputStream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(InputStream input) throws IOException, UnsupportedAudioFileException
{
loadInfo(input);
}
/**
* Load info from input stream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
/**
* Load Ogg Vorbis info from file.
*
* @param file
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
loadInfo(aff);
}
/**
* Load Ogg Vorbis info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
loadExtendedInfo(aff);
}
/**
* Load info from AudioFileFormat.
*
* @param aff
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException
{
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("ogg")) throw new UnsupportedAudioFileException("Not Ogg Vorbis audio format");
if (aff instanceof TAudioFileFormat)
{
Map props = ((TAudioFileFormat) aff).properties();
if (props.containsKey("ogg.channels")) channels = ((Integer) props.get("ogg.channels")).intValue();
if (props.containsKey("ogg.frequency.hz")) rate = ((Integer) props.get("ogg.frequency.hz")).intValue();
if (props.containsKey("ogg.bitrate.nominal.bps")) nominalbitrate = ((Integer) props.get("ogg.bitrate.nominal.bps")).intValue();
averagebitrate = nominalbitrate;
if (props.containsKey("ogg.bitrate.max.bps")) maxbitrate = ((Integer) props.get("ogg.bitrate.max.bps")).intValue();
if (props.containsKey("ogg.bitrate.min.bps")) minbitrate = ((Integer) props.get("ogg.bitrate.min.bps")).intValue();
if (props.containsKey("ogg.version")) version = ((Integer) props.get("ogg.version")).intValue();
if (props.containsKey("ogg.serial")) serial = ((Integer) props.get("ogg.serial")).intValue();
if (props.containsKey("ogg.comment.encodedby")) vendor = (String) props.get("ogg.comment.encodedby");
if (props.containsKey("copyright")) comments.add((String) props.get("copyright"));
if (props.containsKey("title")) title = (String) props.get("title");
if (props.containsKey("author")) artist = (String) props.get("author");
if (props.containsKey("album")) album = (String) props.get("album");
if (props.containsKey("date")) year = (String) props.get("date");
if (props.containsKey("comment")) comments.add((String) props.get("comment"));
if (props.containsKey("duration")) totalms = (long) Math.round((((Long) props.get("duration")).longValue()) / 1000000);
if (props.containsKey("ogg.comment.genre")) genre = (String) props.get("ogg.comment.genre");
if (props.containsKey("ogg.comment.track"))
{
try
{
track = Integer.parseInt((String) props.get("ogg.comment.track"));
}
catch (NumberFormatException e1)
{
// Not a number
}
}
if (props.containsKey("ogg.comment.ext.1")) comments.add((String) props.get("ogg.comment.ext.1"));
if (props.containsKey("ogg.comment.ext.2")) comments.add((String) props.get("ogg.comment.ext.2"));
if (props.containsKey("ogg.comment.ext.3")) comments.add((String) props.get("ogg.comment.ext.3"));
}
}
/**
* Load extended info from AudioFileFormat.
*
* @param aff
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadExtendedInfo(AudioFileFormat aff) throws IOException, UnsupportedAudioFileException
{
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("ogg")) throw new UnsupportedAudioFileException("Not Ogg Vorbis audio format");
if (aff instanceof TAudioFileFormat)
{
//Map props = ((TAudioFileFormat) aff).properties();
// How to load icecast meta data (if any) ??
}
}
public int getSerial()
{
return serial;
}
public int getChannels()
{
return channels;
}
public int getVersion()
{
return version;
}
public int getMinBitrate()
{
return minbitrate;
}
public int getMaxBitrate()
{
return maxbitrate;
}
public int getAverageBitrate()
{
return averagebitrate;
}
public long getSize()
{
return size;
}
public String getVendor()
{
return vendor;
}
public String getLocation()
{
return location;
}
/*-- TagInfo Implementation --*/
public int getSamplingRate()
{
return rate;
}
public int getBitRate()
{
return nominalbitrate;
}
public long getPlayTime()
{
return totalms;
}
public String getTitle()
{
return title;
}
public String getArtist()
{
return artist;
}
public String getAlbum()
{
return album;
}
public int getTrack()
{
return track;
}
public String getGenre()
{
return genre;
}
public Vector getComment()
{
return comments;
}
public String getYear()
{
return year;
}
} | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/OggVorbisInfo.java | Java | asf20 | 9,454 |
/*
* FlacDialog.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag.ui;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.FlacInfo;
/**
* FlacDialog class implements a DialogBox to diplay Flac info.
*/
public class FlacDialog extends TagInfoDialog
{
private FlacInfo _flacinfo = null;
/**
* Creates new form FlacDialog
*/
public FlacDialog(JFrame parent, String title, FlacInfo mi)
{
super(parent, title);
initComponents();
_flacinfo = mi;
int size = _flacinfo.getLocation().length();
locationLabel.setText(size > 50 ? ("..." + _flacinfo.getLocation().substring(size - 50)) : _flacinfo.getLocation());
if ((_flacinfo.getTitle() != null) && (!_flacinfo.getTitle().equals(""))) textField.append("Title=" + _flacinfo.getTitle() + "\n");
if ((_flacinfo.getArtist() != null) && (!_flacinfo.getArtist().equals(""))) textField.append("Artist=" + _flacinfo.getArtist() + "\n");
if ((_flacinfo.getAlbum() != null) && (!_flacinfo.getAlbum().equals(""))) textField.append("Album=" + _flacinfo.getAlbum() + "\n");
if (_flacinfo.getTrack() > 0) textField.append("Track=" + _flacinfo.getTrack() + "\n");
if ((_flacinfo.getYear() != null) && (!_flacinfo.getYear().equals(""))) textField.append("Year=" + _flacinfo.getYear() + "\n");
if ((_flacinfo.getGenre() != null) && (!_flacinfo.getGenre().equals(""))) textField.append("Genre=" + _flacinfo.getGenre() + "\n");
java.util.List comments = _flacinfo.getComment();
if (comments != null)
{
for (int i = 0; i < comments.size(); i++)
textField.append(comments.get(i) + "\n");
}
DecimalFormat df = new DecimalFormat("#,###,###");
sizeLabel.setText("Size : " + df.format(_flacinfo.getSize()) + " bytes");
channelsLabel.setText("Channels: " + _flacinfo.getChannels());
bitspersampleLabel.setText("Bits Per Sample: " + _flacinfo.getBitsPerSample());
samplerateLabel.setText("Sample Rate: " + _flacinfo.getSamplingRate() + " Hz");
buttonsPanel.add(_close);
pack();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
jPanel3 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
locationLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
textField = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
lengthLabel = new javax.swing.JLabel();
sizeLabel = new javax.swing.JLabel();
channelsLabel = new javax.swing.JLabel();
bitspersampleLabel = new javax.swing.JLabel();
bitrateLabel = new javax.swing.JLabel();
samplerateLabel = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jPanel3.setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("File/URL :");
jPanel1.add(jLabel1);
jPanel1.add(locationLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel1, gridBagConstraints);
jLabel2.setText("Standard Tags");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel2, gridBagConstraints);
jLabel3.setText("File/Stream info");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel3, gridBagConstraints);
textField.setColumns(20);
textField.setRows(10);
jScrollPane1.setViewportView(textField);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jScrollPane1, gridBagConstraints);
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
jPanel2.add(lengthLabel);
jPanel2.add(sizeLabel);
jPanel2.add(channelsLabel);
jPanel2.add(bitspersampleLabel);
jPanel2.add(bitrateLabel);
jPanel2.add(samplerateLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel2, gridBagConstraints);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel bitrateLabel;
private javax.swing.JLabel bitspersampleLabel;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel channelsLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lengthLabel;
private javax.swing.JLabel locationLabel;
private javax.swing.JLabel samplerateLabel;
private javax.swing.JLabel sizeLabel;
private javax.swing.JTextArea textField;
// End of variables declaration//GEN-END:variables
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/ui/FlacDialog.java | Java | asf20 | 7,886 |
/*
* MpegDialog.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag.ui;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.MpegInfo;
/**
* OggVorbisDialog class implements a DialogBox to diplay OggVorbis info.
*/
public class MpegDialog extends TagInfoDialog
{
private MpegInfo _mpeginfo = null;
/**
* Creates new form MpegDialog
*/
public MpegDialog(JFrame parent, String title, MpegInfo mi)
{
super(parent, title);
initComponents();
_mpeginfo = mi;
int size = _mpeginfo.getLocation().length();
locationLabel.setText(size > 50 ? ("..." + _mpeginfo.getLocation().substring(size - 50)) : _mpeginfo.getLocation());
if ((_mpeginfo.getTitle() != null) && ((!_mpeginfo.getTitle().equals("")))) textField.append("Title=" + _mpeginfo.getTitle() + "\n");
if ((_mpeginfo.getArtist() != null) && ((!_mpeginfo.getArtist().equals("")))) textField.append("Artist=" + _mpeginfo.getArtist() + "\n");
if ((_mpeginfo.getAlbum() != null) && ((!_mpeginfo.getAlbum().equals("")))) textField.append("Album=" + _mpeginfo.getAlbum() + "\n");
if (_mpeginfo.getTrack() > 0) textField.append("Track=" + _mpeginfo.getTrack() + "\n");
if ((_mpeginfo.getYear() != null) && ((!_mpeginfo.getYear().equals("")))) textField.append("Year=" + _mpeginfo.getYear() + "\n");
if ((_mpeginfo.getGenre() != null) && ((!_mpeginfo.getGenre().equals("")))) textField.append("Genre=" + _mpeginfo.getGenre() + "\n");
java.util.List comments = _mpeginfo.getComment();
if (comments != null)
{
for (int i = 0; i < comments.size(); i++)
textField.append(comments.get(i) + "\n");
}
int secondsAmount = Math.round(_mpeginfo.getPlayTime());
if (secondsAmount < 0) secondsAmount = 0;
int minutes = secondsAmount / 60;
int seconds = secondsAmount - (minutes * 60);
lengthLabel.setText("Length : " + minutes + ":" + seconds);
DecimalFormat df = new DecimalFormat("#,###,###");
sizeLabel.setText("Size : " + df.format(_mpeginfo.getSize()) + " bytes");
versionLabel.setText(_mpeginfo.getVersion() + " " + _mpeginfo.getLayer());
bitrateLabel.setText((_mpeginfo.getBitRate() / 1000) + " kbps");
samplerateLabel.setText(_mpeginfo.getSamplingRate() + " Hz " + _mpeginfo.getChannelsMode());
vbrLabel.setText("VBR : " + _mpeginfo.getVBR());
crcLabel.setText("CRCs : " + _mpeginfo.getCRC());
copyrightLabel.setText("Copyrighted : " + _mpeginfo.getCopyright());
originalLabel.setText("Original : " + _mpeginfo.getOriginal());
emphasisLabel.setText("Emphasis : " + _mpeginfo.getEmphasis());
buttonsPanel.add(_close);
pack();
}
/**
* Returns VorbisInfo.
*/
public MpegInfo getOggVorbisInfo()
{
return _mpeginfo;
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
jPanel3 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
locationLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
textField = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
lengthLabel = new javax.swing.JLabel();
sizeLabel = new javax.swing.JLabel();
versionLabel = new javax.swing.JLabel();
bitrateLabel = new javax.swing.JLabel();
samplerateLabel = new javax.swing.JLabel();
vbrLabel = new javax.swing.JLabel();
crcLabel = new javax.swing.JLabel();
copyrightLabel = new javax.swing.JLabel();
originalLabel = new javax.swing.JLabel();
emphasisLabel = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jPanel3.setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("File/URL :");
jPanel1.add(jLabel1);
jPanel1.add(locationLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel1, gridBagConstraints);
jLabel2.setText("Standard Tags");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel2, gridBagConstraints);
jLabel3.setText("File/Stream info");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel3, gridBagConstraints);
textField.setColumns(20);
textField.setRows(10);
jScrollPane1.setViewportView(textField);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jScrollPane1, gridBagConstraints);
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
jPanel2.add(lengthLabel);
jPanel2.add(sizeLabel);
jPanel2.add(versionLabel);
jPanel2.add(bitrateLabel);
jPanel2.add(samplerateLabel);
jPanel2.add(vbrLabel);
jPanel2.add(crcLabel);
jPanel2.add(copyrightLabel);
jPanel2.add(originalLabel);
jPanel2.add(emphasisLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel2, gridBagConstraints);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel bitrateLabel;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel copyrightLabel;
private javax.swing.JLabel crcLabel;
private javax.swing.JLabel emphasisLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lengthLabel;
private javax.swing.JLabel locationLabel;
private javax.swing.JLabel originalLabel;
private javax.swing.JLabel samplerateLabel;
private javax.swing.JLabel sizeLabel;
private javax.swing.JTextArea textField;
private javax.swing.JLabel vbrLabel;
private javax.swing.JLabel versionLabel;
// End of variables declaration//GEN-END:variables
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/ui/MpegDialog.java | Java | asf20 | 9,079 |
/*
* EmptyDialog.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag.ui;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.TagInfo;
/**
* OggVorbisDialog class implements a DialogBox to diplay OggVorbis info.
*/
public class EmptyDialog extends TagInfoDialog
{
private TagInfo _info = null;
/**
* Creates new form MpegDialog
*/
public EmptyDialog(JFrame parent, String title, TagInfo mi)
{
super(parent, title);
initComponents();
_info = mi;
buttonsPanel.add(_close);
pack();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("No Information Available");
jPanel3.add(jLabel1);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel3;
// End of variables declaration//GEN-END:variables
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/ui/EmptyDialog.java | Java | asf20 | 2,800 |
/*
* TagInfoDialog.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
/**
* This class define a Dialog for TagiInfo to display.
*/
public class TagInfoDialog extends JDialog implements ActionListener
{
protected JButton _close = null;
/**
* Constructor.
* @param parent
* @param title
*/
public TagInfoDialog(JFrame parent, String title)
{
super(parent, title, true);
_close = new JButton("Close");
_close.addActionListener(this);
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == _close)
{
this.dispose();
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/ui/TagInfoDialog.java | Java | asf20 | 1,946 |
/*
* APEDialog.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag.ui;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.APEInfo;
/**
* APEDialog class implements a DialogBox to diplay APE info.
*/
public class APEDialog extends TagInfoDialog
{
private APEInfo _apeinfo = null;
/**
* Creates new form ApeDialog
*/
public APEDialog(JFrame parent, String title, APEInfo mi)
{
super(parent, title);
initComponents();
_apeinfo = mi;
int size = _apeinfo.getLocation().length();
locationLabel.setText(size > 50 ? ("..." + _apeinfo.getLocation().substring(size - 50)) : _apeinfo.getLocation());
if ((_apeinfo.getTitle() != null) && (!_apeinfo.getTitle().equals(""))) textField.append("Title=" + _apeinfo.getTitle() + "\n");
if ((_apeinfo.getArtist() != null) && (!_apeinfo.getArtist().equals(""))) textField.append("Artist=" + _apeinfo.getArtist() + "\n");
if ((_apeinfo.getAlbum() != null) && (!_apeinfo.getAlbum().equals(""))) textField.append("Album=" + _apeinfo.getAlbum() + "\n");
if (_apeinfo.getTrack() > 0) textField.append("Track=" + _apeinfo.getTrack() + "\n");
if ((_apeinfo.getYear() != null) && (!_apeinfo.getYear().equals(""))) textField.append("Year=" + _apeinfo.getYear() + "\n");
if ((_apeinfo.getGenre() != null) && (!_apeinfo.getGenre().equals(""))) textField.append("Genre=" + _apeinfo.getGenre() + "\n");
java.util.List comments = _apeinfo.getComment();
if (comments != null)
{
for (int i = 0; i < comments.size(); i++)
textField.append(comments.get(i) + "\n");
}
int secondsAmount = Math.round(_apeinfo.getPlayTime());
if (secondsAmount < 0) secondsAmount = 0;
int minutes = secondsAmount / 60;
int seconds = secondsAmount - (minutes * 60);
lengthLabel.setText("Length : " + minutes + ":" + seconds);
DecimalFormat df = new DecimalFormat("#,###,###");
sizeLabel.setText("Size : " + df.format(_apeinfo.getSize()) + " bytes");
versionLabel.setText("Version: " + df.format(_apeinfo.getVersion()));
compressionLabel.setText("Compression: " + _apeinfo.getCompressionlevel());
channelsLabel.setText("Channels: " + _apeinfo.getChannels());
bitspersampleLabel.setText("Bits Per Sample: " + _apeinfo.getBitsPerSample());
bitrateLabel.setText("Average Bitrate: " + (_apeinfo.getBitRate() / 1000) + " kbps");
samplerateLabel.setText("Sample Rate: " + _apeinfo.getSamplingRate() + " Hz");
peaklevelLabel.setText("Peak Level: " + (_apeinfo.getPeaklevel() > 0 ? String.valueOf(_apeinfo.getPeaklevel()) : ""));
copyrightLabel.setText("Copyrighted: " + (_apeinfo.getCopyright() != null ? _apeinfo.getCopyright() : ""));
buttonsPanel.add(_close);
pack();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
jPanel3 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
locationLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
textField = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
lengthLabel = new javax.swing.JLabel();
sizeLabel = new javax.swing.JLabel();
versionLabel = new javax.swing.JLabel();
compressionLabel = new javax.swing.JLabel();
channelsLabel = new javax.swing.JLabel();
bitspersampleLabel = new javax.swing.JLabel();
bitrateLabel = new javax.swing.JLabel();
samplerateLabel = new javax.swing.JLabel();
peaklevelLabel = new javax.swing.JLabel();
copyrightLabel = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jPanel3.setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("File/URL :");
jPanel1.add(jLabel1);
jPanel1.add(locationLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel1, gridBagConstraints);
jLabel2.setText("Standard Tags");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel2, gridBagConstraints);
jLabel3.setText("File/Stream info");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel3, gridBagConstraints);
textField.setColumns(20);
textField.setRows(10);
jScrollPane1.setViewportView(textField);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jScrollPane1, gridBagConstraints);
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
jPanel2.add(lengthLabel);
jPanel2.add(sizeLabel);
jPanel2.add(versionLabel);
jPanel2.add(compressionLabel);
jPanel2.add(channelsLabel);
jPanel2.add(bitspersampleLabel);
jPanel2.add(bitrateLabel);
jPanel2.add(samplerateLabel);
jPanel2.add(peaklevelLabel);
jPanel2.add(copyrightLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel2, gridBagConstraints);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel bitrateLabel;
private javax.swing.JLabel bitspersampleLabel;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel channelsLabel;
private javax.swing.JLabel compressionLabel;
private javax.swing.JLabel copyrightLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lengthLabel;
private javax.swing.JLabel locationLabel;
private javax.swing.JLabel peaklevelLabel;
private javax.swing.JLabel samplerateLabel;
private javax.swing.JLabel sizeLabel;
private javax.swing.JTextArea textField;
private javax.swing.JLabel versionLabel;
// End of variables declaration//GEN-END:variables
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/ui/APEDialog.java | Java | asf20 | 9,167 |
/*
* TagSearch.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag.ui;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ResourceBundle;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javazoom.jlgui.player.amp.PlayerUI;
import javazoom.jlgui.player.amp.playlist.Playlist;
import javazoom.jlgui.player.amp.playlist.PlaylistItem;
import javazoom.jlgui.player.amp.tag.TagInfo;
/**
* This class allows to search and play for a particular track in the current playlist.
*/
public class TagSearch extends JFrame
{
private static String sep = System.getProperty("file.separator");
private JTextField searchField;
private JList list;
private DefaultListModel m;
private PlayerUI player;
private Vector _playlist, restrictedPlaylist;
private String lastSearch = null;
private JScrollPane scroll;
private ResourceBundle bundle;
private JRadioButton all, artist, album, title;
public TagSearch(PlayerUI ui)
{
super();
player = ui;
_playlist = null;
restrictedPlaylist = null;
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/tag/ui/tag");
initComponents();
}
public void display()
{
if (list.getModel().getSize() != 0)
{
setVisible(true);
}
else
{
JOptionPane.showMessageDialog(player.getParent(), bundle.getString("emptyPlaylistMsg"), bundle.getString("emptyPlaylistTitle"), JOptionPane.OK_OPTION);
}
}
/**
* Initialises the User Interface.
*/
private void initComponents()
{
setLayout(new GridLayout(1, 1));
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle(bundle.getString("title"));
this.setLocation(player.getX() + player.getWidth(), player.getY());
JPanel main = new JPanel(new BorderLayout(0, 1));
main.setBorder(new EmptyBorder(10, 10, 10, 10));
main.setMinimumSize(new java.awt.Dimension(0, 0));
main.setPreferredSize(new java.awt.Dimension(300, 400));
JPanel searchPane = new JPanel(new GridLayout(4, 1, 10, 2));
JLabel searchLabel = new JLabel(bundle.getString("searchLabel"));
searchField = new JTextField();
searchField.addKeyListener(new KeyboardListener());
searchPane.add(searchLabel);
searchPane.add(searchField);
all = new JRadioButton(bundle.getString("radioAll"), true);
artist = new JRadioButton(bundle.getString("radioArtist"), false);
album = new JRadioButton(bundle.getString("radioAlbum"), false);
title = new JRadioButton(bundle.getString("radioTitle"), false);
all.addChangeListener(new RadioListener());
ButtonGroup filters = new ButtonGroup();
filters.add(all);
filters.add(artist);
filters.add(album);
filters.add(title);
JPanel topButtons = new JPanel(new GridLayout(1, 2));
JPanel bottomButtons = new JPanel(new GridLayout(1, 2));
topButtons.add(all);
topButtons.add(artist);
bottomButtons.add(album);
bottomButtons.add(title);
searchPane.add(topButtons);
searchPane.add(bottomButtons);
list = new JList();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
initList();
list.addMouseListener(new ClickListener());
list.addKeyListener(new KeyboardListener());
scroll = new JScrollPane(list);
main.add(searchPane, BorderLayout.NORTH);
main.add(scroll, BorderLayout.CENTER);
add(main);
pack();
}
/**
* Initialises the list so that it displays the details of all songs in the playlist.
*/
private void initList()
{
Playlist playlist = player.getPlaylist();
int c = player.getPlaylist().getPlaylistSize();
_playlist = new Vector();
for (int i = 0; i < c; i++)
{
_playlist.addElement(playlist.getItemAt(i));
}
restrictedPlaylist = _playlist;
m = new DefaultListModel();
for (int i = 0; i < _playlist.size(); i++)
{
PlaylistItem plItem = (PlaylistItem) _playlist.get(i);
if (plItem.isFile()) m.addElement(getDisplayString(plItem));
}
list.setModel(m);
}
public String getDisplayString(PlaylistItem pi)
{
TagInfo song = pi.getTagInfo();
String element;
String location = pi.getLocation();
location = location.substring(location.lastIndexOf(sep) + 1, location.lastIndexOf("."));
if (song == null)
{
element = location;
}
else
{
if (song.getArtist() == null || song.getArtist().equals(""))
{
element = location;
}
else
{
element = song.getArtist().trim();
if (song.getTitle() == null || song.getTitle().equals(""))
{
element += " - " + location;
}
else
{
element += " - " + song.getTitle().trim();
}
}
}
return element;
}
/**
* Searches the playlist for a song containing the words in the given search string.
* It searches on the title, artist, album and filename of each song in the playlist.
*
* @param searchString The string to search for in all songs in the playlist
**/
private void searchList(String searchString)
{
String[] s = searchString.split(" ");
String lastS = "";
if (s.length > 0) lastS = s[s.length - 1];
if (lastS.equals(""))
{
list.setModel(m);
restrictedPlaylist = _playlist;
}
else
{
DefaultListModel newModel = new DefaultListModel();
if (lastSearch != null)
{
if (searchString.length() <= 1 || !searchString.substring(searchString.length() - 2).equals(lastSearch))
{
list.setModel(m);
restrictedPlaylist = _playlist;
}
}
Vector pI = restrictedPlaylist;
restrictedPlaylist = new Vector();
for (int a = 0; a < s.length; a++)
{
String currentS = s[a];
int size = list.getModel().getSize();
boolean[] remove = new boolean[size];
for (int i = 0; i < size; i++)
{
final int TITLE_SEARCH = 0;
final int ARTIST_SEARCH = 1;
final int ALBUM_SEARCH = 2;
final int FILENAME_SEARCH = 3;
TagInfo pli = ((PlaylistItem) pI.get(i)).getTagInfo();
remove[i] = false;
boolean found = false;
int searchType;
if (artist.isSelected())
{
searchType = ARTIST_SEARCH;
}
else if (album.isSelected())
{
searchType = ALBUM_SEARCH;
}
else if (title.isSelected())
{
searchType = TITLE_SEARCH;
}
else
{
searchType = -1;
}
for (int j = 0; j <= FILENAME_SEARCH; j++)
{
String listString = "";
if (pli == null)
{
if (searchType != -1)
{
break;
}
j = FILENAME_SEARCH;
}
else if (searchType != -1)
{
j = searchType;
}
switch (j)
{
case (TITLE_SEARCH):
if (pli.getTitle() != null) listString = pli.getTitle().toLowerCase();
break;
case (ARTIST_SEARCH):
if (pli.getArtist() != null) listString = pli.getArtist().toLowerCase();
break;
case (ALBUM_SEARCH):
if (pli.getAlbum() != null) listString = pli.getAlbum().toLowerCase();
break;
case (FILENAME_SEARCH):
String location = ((PlaylistItem) pI.get(i)).getLocation().toLowerCase();
listString = location.substring(location.lastIndexOf(sep) + 1, location.lastIndexOf("."));
break;
}
currentS = currentS.toLowerCase();
if (found = search(currentS, listString))
{
break;
}
if (searchType != -1)
{
break;
}
}
//if(found)foundAt[a] = i;
if (found && a == 0)
{
//todo new
newModel.addElement(getDisplayString((PlaylistItem) pI.get(i)));
restrictedPlaylist.add(pI.get(i));
}
if (!found && a != 0)
{
remove[i] = true;
}
}
//remove all unmatching items
for (int x = size - 1; x >= 0; x--)
{
if (remove[x])
{
newModel.remove(x);
restrictedPlaylist.remove(x);
}
}
pI = restrictedPlaylist;
list.setModel(newModel);
}
list.setModel(newModel);
lastSearch = searchField.getText();
}
if (list.getModel().getSize() > 0) list.setSelectedIndex(0);
}
/**
* Searches to see if a particular string exists within another string
*
* @param pattern The string to search for
* @param text The string in which to search for the pattern string
* @return True if the pattern string exists in the text string
*/
private boolean search(String pattern, String text)
{
int pStart = 0;
int tStart = 0;
char[] pChar = pattern.toCharArray();
char[] tChar = text.toCharArray();
while (pStart < pChar.length && tStart < tChar.length)
{
if (pChar[pStart] == tChar[tStart])
{
pStart++;
tStart++;
}
else
{
pStart = 0;
if (pChar[pStart] != tChar[tStart])
{
tStart++;
}
}
}
return pStart == pChar.length;
}
/**
* Calls the relavent methods in the player class to play a song.
*/
private void playSong()
{
Playlist playlist = player.getPlaylist();
player.pressStop();
player.setCurrentSong((PlaylistItem) restrictedPlaylist.get(list.getSelectedIndex()));
playlist.setCursor(playlist.getIndex((PlaylistItem) restrictedPlaylist.get(list.getSelectedIndex())));
player.pressStart();
dispose();
}
/**
* Class to handle keyboard presses.
*/
class KeyboardListener implements KeyListener
{
public void keyReleased(KeyEvent e)
{
if (e.getSource().equals(searchField))
{
if (e.getKeyCode() != KeyEvent.VK_DOWN && e.getKeyCode() != KeyEvent.VK_UP)
{
searchList(searchField.getText()); // Search for current search string
}
}
}
public void keyTyped(KeyEvent e)
{
if (list.getSelectedIndex() != -1)
{
if (e.getKeyChar() == KeyEvent.VK_ENTER)
{
playSong();
}
}
}
public void keyPressed(KeyEvent e)
{
int index = list.getSelectedIndex();
if (e.getKeyCode() == KeyEvent.VK_DOWN && index < list.getModel().getSize() - 1)
{
//list.setSelectedIndex(index+1);
JScrollBar vBar = scroll.getVerticalScrollBar();
vBar.setValue(vBar.getValue() + vBar.getUnitIncrement() * 5);
}
else if (e.getKeyCode() == KeyEvent.VK_UP && index >= 0)
{
JScrollBar vBar = scroll.getVerticalScrollBar();
vBar.setValue(vBar.getValue() - vBar.getUnitIncrement() * 5);
//list.setSelectedIndex(index-1);
}
}
}
/**
* Class to play a song if one is double-clicked on on the search list.
*/
class ClickListener extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2 && list.getSelectedIndex() != -1)
{
playSong();
}
}
}
class RadioListener implements ChangeListener
{
public void stateChanged(ChangeEvent e)
{
searchList(searchField.getText());
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/ui/TagSearch.java | Java | asf20 | 15,923 |
/*
* OggVorbisDialog.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.tag.ui;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.OggVorbisInfo;
/**
* OggVorbisDialog class implements a DialogBox to diplay OggVorbis info.
*/
public class OggVorbisDialog extends TagInfoDialog
{
private OggVorbisInfo _vorbisinfo = null;
/**
* Creates new form MpegDialog
*/
public OggVorbisDialog(JFrame parent, String title, OggVorbisInfo mi)
{
super(parent, title);
initComponents();
_vorbisinfo = mi;
int size = _vorbisinfo.getLocation().length();
locationLabel.setText(size > 50 ? ("..." + _vorbisinfo.getLocation().substring(size - 50)) : _vorbisinfo.getLocation());
if ((_vorbisinfo.getTitle() != null) && ((!_vorbisinfo.getTitle().equals("")))) textField.append("Title=" + _vorbisinfo.getTitle() + "\n");
if ((_vorbisinfo.getArtist() != null) && ((!_vorbisinfo.getArtist().equals("")))) textField.append("Artist=" + _vorbisinfo.getArtist() + "\n");
if ((_vorbisinfo.getAlbum() != null) && ((!_vorbisinfo.getAlbum().equals("")))) textField.append("Album=" + _vorbisinfo.getAlbum() + "\n");
if (_vorbisinfo.getTrack() > 0) textField.append("Track=" + _vorbisinfo.getTrack() + "\n");
if ((_vorbisinfo.getYear() != null) && ((!_vorbisinfo.getYear().equals("")))) textField.append("Year=" + _vorbisinfo.getYear() + "\n");
if ((_vorbisinfo.getGenre() != null) && ((!_vorbisinfo.getGenre().equals("")))) textField.append("Genre=" + _vorbisinfo.getGenre() + "\n");
java.util.List comments = _vorbisinfo.getComment();
for (int i = 0; i < comments.size(); i++)
textField.append(comments.get(i) + "\n");
int secondsAmount = Math.round(_vorbisinfo.getPlayTime());
if (secondsAmount < 0) secondsAmount = 0;
int minutes = secondsAmount / 60;
int seconds = secondsAmount - (minutes * 60);
lengthLabel.setText("Length : " + minutes + ":" + seconds);
bitrateLabel.setText("Average bitrate : " + _vorbisinfo.getAverageBitrate() / 1000 + " kbps");
DecimalFormat df = new DecimalFormat("#,###,###");
sizeLabel.setText("File size : " + df.format(_vorbisinfo.getSize()) + " bytes");
nominalbitrateLabel.setText("Nominal bitrate : " + (_vorbisinfo.getBitRate() / 1000) + " kbps");
maxbitrateLabel.setText("Max bitrate : " + _vorbisinfo.getMaxBitrate() / 1000 + " kbps");
minbitrateLabel.setText("Min bitrate : " + _vorbisinfo.getMinBitrate() / 1000 + " kbps");
channelsLabel.setText("Channel : " + _vorbisinfo.getChannels());
samplerateLabel.setText("Sampling rate : " + _vorbisinfo.getSamplingRate() + " Hz");
serialnumberLabel.setText("Serial number : " + _vorbisinfo.getSerial());
versionLabel.setText("Version : " + _vorbisinfo.getVersion());
vendorLabel.setText("Vendor : " + _vorbisinfo.getVendor());
buttonsPanel.add(_close);
pack();
}
/**
* Returns VorbisInfo.
*/
public OggVorbisInfo getOggVorbisInfo()
{
return _vorbisinfo;
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
jPanel3 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
locationLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
textField = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
lengthLabel = new javax.swing.JLabel();
bitrateLabel = new javax.swing.JLabel();
sizeLabel = new javax.swing.JLabel();
nominalbitrateLabel = new javax.swing.JLabel();
maxbitrateLabel = new javax.swing.JLabel();
minbitrateLabel = new javax.swing.JLabel();
channelsLabel = new javax.swing.JLabel();
samplerateLabel = new javax.swing.JLabel();
serialnumberLabel = new javax.swing.JLabel();
versionLabel = new javax.swing.JLabel();
vendorLabel = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jPanel3.setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("File/URL :");
jPanel1.add(jLabel1);
jPanel1.add(locationLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel1, gridBagConstraints);
jLabel2.setText("Standard Tags");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel2, gridBagConstraints);
jLabel3.setText("File/Stream info");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel3, gridBagConstraints);
textField.setColumns(20);
textField.setRows(10);
jScrollPane1.setViewportView(textField);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jScrollPane1, gridBagConstraints);
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
jPanel2.add(lengthLabel);
jPanel2.add(bitrateLabel);
jPanel2.add(sizeLabel);
jPanel2.add(nominalbitrateLabel);
jPanel2.add(maxbitrateLabel);
jPanel2.add(minbitrateLabel);
jPanel2.add(channelsLabel);
jPanel2.add(samplerateLabel);
jPanel2.add(serialnumberLabel);
jPanel2.add(versionLabel);
jPanel2.add(vendorLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel2, gridBagConstraints);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel bitrateLabel;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel channelsLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lengthLabel;
private javax.swing.JLabel locationLabel;
private javax.swing.JLabel maxbitrateLabel;
private javax.swing.JLabel minbitrateLabel;
private javax.swing.JLabel nominalbitrateLabel;
private javax.swing.JLabel samplerateLabel;
private javax.swing.JLabel serialnumberLabel;
private javax.swing.JLabel sizeLabel;
private javax.swing.JTextArea textField;
private javax.swing.JLabel vendorLabel;
private javax.swing.JLabel versionLabel;
// End of variables declaration//GEN-END:variables
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/tag/ui/OggVorbisDialog.java | Java | asf20 | 9,561 |
/*
* PlaylistItem.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*
*/
package javazoom.jlgui.player.amp.playlist;
import javazoom.jlgui.player.amp.tag.TagInfo;
import javazoom.jlgui.player.amp.tag.TagInfoFactory;
import javazoom.jlgui.player.amp.util.Config;
import javazoom.jlgui.player.amp.util.FileUtil;
/**
* This class implements item for playlist.
*/
public class PlaylistItem
{
protected String _name = null;
protected String _displayName = null;
protected String _location = null;
protected boolean _isFile = true;
protected long _seconds = -1;
protected boolean _isSelected = false; // add by JOHN YANG
protected TagInfo _taginfo = null;
protected PlaylistItem()
{
}
/**
* Contructor for playlist item.
*
* @param name Song name to be displayed
* @param location File or URL
* @param seconds Time length
* @param isFile true for File instance
*/
public PlaylistItem(String name, String location, long seconds, boolean isFile)
{
_name = name;
_seconds = seconds;
_isFile = isFile;
Config config = Config.getInstance();
if (config.getTaginfoPolicy().equals(Config.TAGINFO_POLICY_ALL))
{
// Read tag info for any File or URL. It could take time.
setLocation(location, true);
}
else if (config.getTaginfoPolicy().equals(Config.TAGINFO_POLICY_FILE))
{
// Read tag info for any File only not for URL.
if (_isFile) setLocation(location, true);
else setLocation(location, false);
}
else
{
// Do not read tag info.
setLocation(location, false);
}
}
/**
* Returns item name such as (hh:mm:ss) Title - Artist if available.
*
* @return
*/
public String getFormattedName()
{
if (_displayName == null)
{
if (_seconds > 0)
{
String length = getFormattedLength();
return "(" + length + ") " + _name;
}
else return _name;
}
// Name extracted from TagInfo or stream title.
else return _displayName;
}
public String getName()
{
return _name;
}
public String getLocation()
{
return _location;
}
/**
* Returns true if item to play is coming for a file.
*
* @return
*/
public boolean isFile()
{
return _isFile;
}
/**
* Set File flag for playslit item.
*
* @param b
*/
public void setFile(boolean b)
{
_isFile = b;
}
/**
* Returns playtime in seconds. If tag info is available then its playtime will be returned.
*
* @return playtime
*/
public long getLength()
{
if ((_taginfo != null) && (_taginfo.getPlayTime() > 0)) return _taginfo.getPlayTime();
else return _seconds;
}
public int getBitrate()
{
if (_taginfo != null) return _taginfo.getBitRate();
else return -1;
}
public int getSamplerate()
{
if (_taginfo != null) return _taginfo.getSamplingRate();
else return -1;
}
public int getChannels()
{
if (_taginfo != null) return _taginfo.getChannels();
else return -1;
}
public void setSelected(boolean mode)
{
_isSelected = mode;
}
public boolean isSelected()
{
return _isSelected;
}
/**
* Reads file comments/tags.
*
* @param l
*/
public void setLocation(String l)
{
setLocation(l, false);
}
/**
* Reads (or not) file comments/tags.
*
* @param l input location
* @param readInfo
*/
public void setLocation(String l, boolean readInfo)
{
_location = l;
if (readInfo == true)
{
// Read Audio Format and read tags/comments.
if ((_location != null) && (!_location.equals("")))
{
TagInfoFactory factory = TagInfoFactory.getInstance();
_taginfo = factory.getTagInfo(l);
}
}
_displayName = getFormattedDisplayName();
}
/**
* Returns item lenght such as hh:mm:ss
*
* @return formatted String.
*/
public String getFormattedLength()
{
long time = getLength();
String length = "";
if (time > -1)
{
int minutes = (int) Math.floor(time / 60);
int hours = (int) Math.floor(minutes / 60);
minutes = minutes - hours * 60;
int seconds = (int) (time - minutes * 60 - hours * 3600);
// Hours.
if (hours > 0)
{
length = length + FileUtil.rightPadString(hours + "", '0', 2) + ":";
}
length = length + FileUtil.rightPadString(minutes + "", '0', 2) + ":" + FileUtil.rightPadString(seconds + "", '0', 2);
}
else length = "" + time;
return length;
}
/**
* Returns item name such as (hh:mm:ss) Title - Artist
*
* @return formatted String.
*/
public String getFormattedDisplayName()
{
if (_taginfo == null) return null;
else
{
String length = getFormattedLength();
if ((_taginfo.getTitle() != null) && (!_taginfo.getTitle().equals("")) && (_taginfo.getArtist() != null) && (!_taginfo.getArtist().equals("")))
{
if (getLength() > 0) return ("(" + length + ") " + _taginfo.getTitle() + " - " + _taginfo.getArtist());
else return (_taginfo.getTitle() + " - " + _taginfo.getArtist());
}
else if ((_taginfo.getTitle() != null) && (!_taginfo.getTitle().equals("")))
{
if (getLength() > 0) return ("(" + length + ") " + _taginfo.getTitle());
else return (_taginfo.getTitle());
}
else
{
if (getLength() > 0) return ("(" + length + ") " + _name);
else return (_name);
}
}
}
public void setFormattedDisplayName(String fname)
{
_displayName = fname;
}
/**
* Return item name such as hh:mm:ss,Title,Artist
*
* @return formatted String.
*/
public String getM3UExtInf()
{
if (_taginfo == null)
{
return (_seconds + "," + _name);
}
else
{
if ((_taginfo.getTitle() != null) && (_taginfo.getArtist() != null))
{
return (getLength() + "," + _taginfo.getTitle() + " - " + _taginfo.getArtist());
}
else if (_taginfo.getTitle() != null)
{
return (getLength() + "," + _taginfo.getTitle());
}
else
{
return (_seconds + "," + _name);
}
}
}
/**
* Return TagInfo.
*
* @return
*/
public TagInfo getTagInfo()
{
if (_taginfo == null)
{
// Inspect location
setLocation(_location, true);
}
return _taginfo;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistItem.java | Java | asf20 | 8,513 |
/*
* Playlist.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.playlist;
import java.util.Collection;
/**
* Playlist.
* This interface defines method that a playlist should implement.<br>
* A playlist provides a collection of item to play and a cursor to know
* which item is playing.
*/
public interface Playlist
{
// Next methods will be called by the Playlist UI.
/**
* Loads playlist.
*/
public boolean load(String filename);
/**
* Saves playlist.
*/
public boolean save(String filename);
/**
* Adds item at a given position in the playlist.
*/
public void addItemAt(PlaylistItem pli, int pos);
/**
* Searchs and removes item from the playlist.
*/
public void removeItem(PlaylistItem pli);
/**
* Removes item at a given position from the playlist.
*/
public void removeItemAt(int pos);
/**
* Removes all items in the playlist.
*/
public void removeAllItems();
/**
* Append item at the end of the playlist.
*/
public void appendItem(PlaylistItem pli);
/**
* Sorts items of the playlist.
*/
public void sortItems(int sortmode);
/**
* Returns item at a given position from the playlist.
*/
public PlaylistItem getItemAt(int pos);
/**
* Returns a collection of playlist items.
*/
public Collection getAllItems();
/**
* Returns then number of items in the playlist.
*/
public int getPlaylistSize();
// Next methods will be used by the Player
/**
* Randomly re-arranges the playlist.
*/
public void shuffle();
/**
* Returns item matching to the cursor.
*/
public PlaylistItem getCursor();
/**
* Moves the cursor at the begining of the Playlist.
*/
public void begin();
/**
* Returns item matching to the cursor.
*/
public int getSelectedIndex();
/**
* Returns index of playlist item.
*/
public int getIndex(PlaylistItem pli);
/**
* Computes cursor position (next).
*/
public void nextCursor();
/**
* Computes cursor position (previous).
*/
public void previousCursor();
/**
* Set the modification flag for the playlist
*/
boolean setModified(boolean set);
/**
* Checks the modification flag
*/
public boolean isModified();
void setCursor(int index);
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/playlist/Playlist.java | Java | asf20 | 3,546 |
/*
* BasePlaylist.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.playlist;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Collection;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;
import javazoom.jlgui.player.amp.util.Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* BasePlaylist implementation.
* This class implements Playlist interface using a Vector.
* It support .m3u and .pls playlist format.
*/
public class BasePlaylist implements Playlist
{
protected Vector _playlist = null;
protected int _cursorPos = -1;
protected boolean isModified;
protected String M3UHome = null;
protected String PLSHome = null;
private static Log log = LogFactory.getLog(BasePlaylist.class);
/**
* Constructor.
*/
public BasePlaylist()
{
_playlist = new Vector();
}
public boolean isModified()
{
return isModified;
}
/**
* Loads playlist as M3U format.
*/
public boolean load(String filename)
{
setModified(true);
boolean loaded = false;
if ((filename != null) && (filename.toLowerCase().endsWith(".m3u")))
{
loaded = loadM3U(filename);
}
else if ((filename != null) && (filename.toLowerCase().endsWith(".pls")))
{
loaded = loadPLS(filename);
}
return loaded;
}
/**
* Load playlist from M3U format.
*
* @param filename
* @return
*/
protected boolean loadM3U(String filename)
{
Config config = Config.getInstance();
_playlist = new Vector();
boolean loaded = false;
BufferedReader br = null;
try
{
// Playlist from URL ? (http:, ftp:, file: ....)
if (Config.startWithProtocol(filename))
{
br = new BufferedReader(new InputStreamReader((new URL(filename)).openStream()));
}
else
{
br = new BufferedReader(new FileReader(filename));
}
String line = null;
String songName = null;
String songFile = null;
String songLength = null;
while ((line = br.readLine()) != null)
{
if (line.trim().length() == 0) continue;
if (line.startsWith("#"))
{
if (line.toUpperCase().startsWith("#EXTINF"))
{
int indA = line.indexOf(",", 0);
if (indA != -1)
{
songName = line.substring(indA + 1, line.length());
}
int indB = line.indexOf(":", 0);
if (indB != -1)
{
if (indB < indA) songLength = (line.substring(indB + 1, indA)).trim();
}
}
}
else
{
songFile = line;
if (songName == null) songName = songFile;
if (songLength == null) songLength = "-1";
PlaylistItem pli = null;
if (Config.startWithProtocol(songFile))
{
// URL.
pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), false);
}
else
{
// File.
File f = new File(songFile);
if (f.exists())
{
pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), true);
}
else
{
// Try relative path.
f = new File(config.getLastDir() + songFile);
if (f.exists())
{
pli = new PlaylistItem(songName, config.getLastDir() + songFile, Long.parseLong(songLength), true);
}
else
{
// Try optional M3U home.
if (M3UHome != null)
{
if (Config.startWithProtocol(M3UHome))
{
pli = new PlaylistItem(songName, M3UHome + songFile, Long.parseLong(songLength), false);
}
else
{
pli = new PlaylistItem(songName, M3UHome + songFile, Long.parseLong(songLength), true);
}
}
}
}
}
if (pli != null) this.appendItem(pli);
songFile = null;
songName = null;
songLength = null;
}
}
loaded = true;
}
catch (Exception e)
{
log.debug("Can't load .m3u playlist", e);
}
finally
{
try
{
if (br != null)
{
br.close();
}
}
catch (Exception ioe)
{
log.info("Can't close .m3u playlist", ioe);
}
}
return loaded;
}
/**
* Load playlist in PLS format.
*
* @param filename
* @return
*/
protected boolean loadPLS(String filename)
{
Config config = Config.getInstance();
_playlist = new Vector();
boolean loaded = false;
BufferedReader br = null;
try
{
// Playlist from URL ? (http:, ftp:, file: ....)
if (Config.startWithProtocol(filename))
{
br = new BufferedReader(new InputStreamReader((new URL(filename)).openStream()));
}
else
{
br = new BufferedReader(new FileReader(filename));
}
String line = null;
String songName = null;
String songFile = null;
String songLength = null;
while ((line = br.readLine()) != null)
{
if (line.trim().length() == 0) continue;
if ((line.toLowerCase().startsWith("file")))
{
StringTokenizer st = new StringTokenizer(line, "=");
st.nextToken();
songFile = st.nextToken().trim();
}
else if ((line.toLowerCase().startsWith("title")))
{
StringTokenizer st = new StringTokenizer(line, "=");
st.nextToken();
songName = st.nextToken().trim();
}
else if ((line.toLowerCase().startsWith("length")))
{
StringTokenizer st = new StringTokenizer(line, "=");
st.nextToken();
songLength = st.nextToken().trim();
}
// New entry ?
if (songFile != null)
{
PlaylistItem pli = null;
if (songName == null) songName = songFile;
if (songLength == null) songLength = "-1";
if (Config.startWithProtocol(songFile))
{
// URL.
pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), false);
}
else
{
// File.
File f = new File(songFile);
if (f.exists())
{
pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), true);
}
else
{
// Try relative path.
f = new File(config.getLastDir() + songFile);
if (f.exists())
{
pli = new PlaylistItem(songName, config.getLastDir() + songFile, Long.parseLong(songLength), true);
}
else
{
// Try optional PLS home.
if (PLSHome != null)
{
if (Config.startWithProtocol(PLSHome))
{
pli = new PlaylistItem(songName, PLSHome + songFile, Long.parseLong(songLength), false);
}
else
{
pli = new PlaylistItem(songName, PLSHome + songFile, Long.parseLong(songLength), true);
}
}
}
}
}
if (pli != null) this.appendItem(pli);
songName = null;
songFile = null;
songLength = null;
}
}
loaded = true;
}
catch (Exception e)
{
log.debug("Can't load .pls playlist", e);
}
finally
{
try
{
if (br != null)
{
br.close();
}
}
catch (Exception ioe)
{
log.info("Can't close .pls playlist", ioe);
}
}
return loaded;
}
/**
* Saves playlist in M3U format.
*/
public boolean save(String filename)
{
// Implemented by C.K
if (_playlist != null)
{
BufferedWriter bw = null;
try
{
bw = new BufferedWriter(new FileWriter(filename));
bw.write("#EXTM3U");
bw.newLine();
Iterator it = _playlist.iterator();
while (it.hasNext())
{
PlaylistItem pli = (PlaylistItem) it.next();
bw.write("#EXTINF:" + pli.getM3UExtInf());
bw.newLine();
bw.write(pli.getLocation());
bw.newLine();
}
return true;
}
catch (IOException e)
{
log.info("Can't save playlist", e);
}
finally
{
try
{
if (bw != null)
{
bw.close();
}
}
catch (IOException ioe)
{
log.info("Can't close playlist", ioe);
}
}
}
return false;
}
/**
* Adds item at a given position in the playlist.
*/
public void addItemAt(PlaylistItem pli, int pos)
{
_playlist.insertElementAt(pli, pos);
setModified(true);
}
/**
* Searchs and removes item from the playlist.
*/
public void removeItem(PlaylistItem pli)
{
_playlist.remove(pli);
setModified(true);
}
/**
* Removes item at a given position from the playlist.
*/
public void removeItemAt(int pos)
{
_playlist.removeElementAt(pos);
setModified(true);
}
/**
* Removes all items from the playlist.
*/
public void removeAllItems()
{
_playlist.removeAllElements();
_cursorPos = -1;
setModified(true);
}
/**
* Append item at the end of the playlist.
*/
public void appendItem(PlaylistItem pli)
{
_playlist.addElement(pli);
setModified(true);
}
/**
* Sorts items of the playlist.
*/
public void sortItems(int sortmode)
{
// TODO
}
/**
* Shuffles items in the playlist randomly
*/
public void shuffle()
{
int size = _playlist.size();
if (size < 2) { return; }
Vector v = _playlist;
_playlist = new Vector(size);
while ((size = v.size()) > 0)
{
_playlist.addElement(v.remove((int) (Math.random() * size)));
}
begin();
}
/**
* Moves the cursor at the top of the playlist.
*/
public void begin()
{
_cursorPos = -1;
if (getPlaylistSize() > 0)
{
_cursorPos = 0;
}
setModified(true);
}
/**
* Returns item at a given position from the playlist.
*/
public PlaylistItem getItemAt(int pos)
{
PlaylistItem pli = null;
pli = (PlaylistItem) _playlist.elementAt(pos);
return pli;
}
/**
* Returns a collection of playlist items.
*/
public Collection getAllItems()
{
// TODO
return null;
}
/**
* Returns then number of items in the playlist.
*/
public int getPlaylistSize()
{
return _playlist.size();
}
// Next methods will be used by the Player
/**
* Returns item matching to the cursor.
*/
public PlaylistItem getCursor()
{
if ((_cursorPos < 0) || (_cursorPos >= _playlist.size())) { return null; }
return getItemAt(_cursorPos);
}
/**
* Computes cursor position (next).
*/
public void nextCursor()
{
_cursorPos++;
}
/**
* Computes cursor position (previous).
*/
public void previousCursor()
{
_cursorPos--;
if (_cursorPos < 0)
{
_cursorPos = 0;
}
}
public boolean setModified(boolean set)
{
isModified = set;
return isModified;
}
public void setCursor(int index)
{
_cursorPos = index;
}
/**
* Returns selected index.
*/
public int getSelectedIndex()
{
return _cursorPos;
}
/**
* Returns index of playlist item.
*/
public int getIndex(PlaylistItem pli)
{
int pos = -1;
for (int i = 0; i < _playlist.size(); i++)
{
pos = i;
PlaylistItem p = (PlaylistItem) _playlist.elementAt(i);
if (p.equals(pli)) break;
}
return pos;
}
/**
* Get M3U home for relative playlist.
*
* @return
*/
public String getM3UHome()
{
return M3UHome;
}
/**
* Set optional M3U home for relative playlist.
*
* @param string
*/
public void setM3UHome(String string)
{
M3UHome = string;
}
/**
* Get PLS home for relative playlist.
*
* @return
*/
public String getPLSHome()
{
return PLSHome;
}
/**
* Set optional PLS home for relative playlist.
*
* @param string
*/
public void setPLSHome(String string)
{
PLSHome = string;
}
} | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/playlist/BasePlaylist.java | Java | asf20 | 17,482 |
/*
* PlaylistFactory.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.playlist;
import java.lang.reflect.Constructor;
import javazoom.jlgui.player.amp.util.Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* PlaylistFactory.
*/
public class PlaylistFactory
{
private static PlaylistFactory _instance = null;
private Playlist _playlistInstance = null;
private Config _config = null;
private static Log log = LogFactory.getLog(PlaylistFactory.class);
/**
* Constructor.
*/
private PlaylistFactory()
{
_config = Config.getInstance();
}
/**
* Returns instance of PlaylistFactory.
*/
public synchronized static PlaylistFactory getInstance()
{
if (_instance == null)
{
_instance = new PlaylistFactory();
}
return _instance;
}
/**
* Returns Playlist instantied from full qualified class name.
*/
public Playlist getPlaylist()
{
if (_playlistInstance == null)
{
String classname = _config.getPlaylistClassName();
boolean interfaceFound = false;
try
{
Class aClass = Class.forName(classname);
Class superClass = aClass;
// Looking for Playlist interface implementation.
while (superClass != null)
{
Class[] interfaces = superClass.getInterfaces();
for (int i = 0; i < interfaces.length; i++)
{
if ((interfaces[i].getName()).equals("javazoom.jlgui.player.amp.playlist.Playlist"))
{
interfaceFound = true;
break;
}
}
if (interfaceFound == true) break;
superClass = superClass.getSuperclass();
}
if (interfaceFound == false)
{
log.error("Error : Playlist implementation not found in " + classname + " hierarchy");
}
else
{
Class[] argsClass = new Class[] {};
Constructor c = aClass.getConstructor(argsClass);
_playlistInstance = (Playlist) (c.newInstance(null));
log.info(classname + " loaded");
}
}
catch (Exception e)
{
log.error("Error : " + classname + " : " + e.getMessage());
}
}
return _playlistInstance;
}
} | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistFactory.java | Java | asf20 | 3,751 |
/*
* PlaylistUI.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.playlist.ui;
import java.awt.Graphics;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javazoom.jlgui.player.amp.PlayerActionEvent;
import javazoom.jlgui.player.amp.PlayerUI;
import javazoom.jlgui.player.amp.playlist.Playlist;
import javazoom.jlgui.player.amp.playlist.PlaylistItem;
import javazoom.jlgui.player.amp.skin.AbsoluteLayout;
import javazoom.jlgui.player.amp.skin.ActiveJButton;
import javazoom.jlgui.player.amp.skin.DropTargetAdapter;
import javazoom.jlgui.player.amp.skin.Skin;
import javazoom.jlgui.player.amp.skin.UrlDialog;
import javazoom.jlgui.player.amp.tag.TagInfo;
import javazoom.jlgui.player.amp.tag.TagInfoFactory;
import javazoom.jlgui.player.amp.tag.ui.TagInfoDialog;
import javazoom.jlgui.player.amp.util.Config;
import javazoom.jlgui.player.amp.util.FileSelector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class PlaylistUI extends JPanel implements ActionListener, ChangeListener
{
private static Log log = LogFactory.getLog(PlaylistUI.class);
public static int MAXDEPTH = 4;
private Config config = null;
private Skin ui = null;
private Playlist playlist = null;
private PlayerUI player = null;
private int topIndex = 0;
private int currentSelection = -1;
private Vector exts = null;
private boolean isSearching = false;
private JPopupMenu fipopup = null;
public PlaylistUI()
{
super();
setDoubleBuffered(true);
setLayout(new AbsoluteLayout());
config = Config.getInstance();
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
handleMouseClick(e);
}
});
// DnD support.
DropTargetAdapter dnd = new DropTargetAdapter()
{
public void processDrop(Object data)
{
processDnD(data);
}
};
DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, true);
}
public void setPlayer(PlayerUI mp)
{
player = mp;
}
public void setSkin(Skin skin)
{
ui = skin;
}
public Skin getSkin()
{
return ui;
}
public Playlist getPlaylist()
{
return playlist;
}
public void setPlaylist(Playlist playlist)
{
this.playlist = playlist;
}
public int getTopIndex()
{
return topIndex;
}
public void loadUI()
{
removeAll();
ui.getPlaylistPanel().setParent(this);
add(ui.getAcPlSlider(), ui.getAcPlSlider().getConstraints());
ui.getAcPlSlider().setValue(100);
ui.getAcPlSlider().removeChangeListener(this);
ui.getAcPlSlider().addChangeListener(this);
add(ui.getAcPlUp(), ui.getAcPlUp().getConstraints());
ui.getAcPlUp().removeActionListener(this);
ui.getAcPlUp().addActionListener(this);
add(ui.getAcPlDown(), ui.getAcPlDown().getConstraints());
ui.getAcPlDown().removeActionListener(this);
ui.getAcPlDown().addActionListener(this);
// Add menu
add(ui.getAcPlAdd(), ui.getAcPlAdd().getConstraints());
ui.getAcPlAdd().removeActionListener(this);
ui.getAcPlAdd().addActionListener(this);
add(ui.getAcPlAddPopup(), ui.getAcPlAddPopup().getConstraints());
ui.getAcPlAddPopup().setVisible(false);
ActiveJButton[] items = ui.getAcPlAddPopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].addActionListener(this);
}
// Remove menu
add(ui.getAcPlRemove(), ui.getAcPlRemove().getConstraints());
ui.getAcPlRemove().removeActionListener(this);
ui.getAcPlRemove().addActionListener(this);
add(ui.getAcPlRemovePopup(), ui.getAcPlRemovePopup().getConstraints());
ui.getAcPlRemovePopup().setVisible(false);
items = ui.getAcPlRemovePopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].removeActionListener(this);
items[i].addActionListener(this);
}
// Select menu
add(ui.getAcPlSelect(), ui.getAcPlSelect().getConstraints());
ui.getAcPlSelect().removeActionListener(this);
ui.getAcPlSelect().addActionListener(this);
add(ui.getAcPlSelectPopup(), ui.getAcPlSelectPopup().getConstraints());
ui.getAcPlSelectPopup().setVisible(false);
items = ui.getAcPlSelectPopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].removeActionListener(this);
items[i].addActionListener(this);
}
// Misc menu
add(ui.getAcPlMisc(), ui.getAcPlMisc().getConstraints());
ui.getAcPlMisc().removeActionListener(this);
ui.getAcPlMisc().addActionListener(this);
add(ui.getAcPlMiscPopup(), ui.getAcPlMiscPopup().getConstraints());
ui.getAcPlMiscPopup().setVisible(false);
items = ui.getAcPlMiscPopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].removeActionListener(this);
items[i].addActionListener(this);
}
// List menu
add(ui.getAcPlList(), ui.getAcPlList().getConstraints());
ui.getAcPlList().removeActionListener(this);
ui.getAcPlList().addActionListener(this);
add(ui.getAcPlListPopup(), ui.getAcPlListPopup().getConstraints());
ui.getAcPlListPopup().setVisible(false);
items = ui.getAcPlListPopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].removeActionListener(this);
items[i].addActionListener(this);
}
// Popup menu
fipopup = new JPopupMenu();
JMenuItem mi = new JMenuItem(ui.getResource("playlist.popup.info"));
mi.setActionCommand(PlayerActionEvent.ACPLINFO);
mi.removeActionListener(this);
mi.addActionListener(this);
fipopup.add(mi);
fipopup.addSeparator();
mi = new JMenuItem(ui.getResource("playlist.popup.play"));
mi.setActionCommand(PlayerActionEvent.ACPLPLAY);
mi.removeActionListener(this);
mi.addActionListener(this);
fipopup.add(mi);
fipopup.addSeparator();
mi = new JMenuItem(ui.getResource("playlist.popup.remove"));
mi.setActionCommand(PlayerActionEvent.ACPLREMOVE);
mi.removeActionListener(this);
mi.addActionListener(this);
fipopup.add(mi);
validate();
repaint();
}
/**
* Initialize playlist.
*/
public void initPlayList()
{
topIndex = 0;
nextCursor();
}
/**
* Repaint the file list area and scroll it if necessary
*/
public void nextCursor()
{
currentSelection = playlist.getSelectedIndex();
int n = playlist.getPlaylistSize();
int nlines = ui.getPlaylistPanel().getLines();
while (currentSelection - topIndex > nlines - 1)
topIndex += 2;
if (topIndex >= n) topIndex = n - 1;
while (currentSelection < topIndex)
topIndex -= 2;
if (topIndex < 0) topIndex = 0;
resetScrollBar();
repaint();
}
/**
* Get the item index according to the mouse y position
* @param y
* @return
*/
protected int getIndex(int y)
{
int n0 = playlist.getPlaylistSize();
if (n0 == 0) return -1;
for (int n = 0; n < 100; n++)
{
if (ui.getPlaylistPanel().isIndexArea(y, n))
{
if (topIndex + n > n0 - 1) return -1;
return topIndex + n;
}
}
return -1;
}
/* (non-Javadoc)
* @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
*/
public void stateChanged(ChangeEvent e)
{
Object src = e.getSource();
//log.debug("State (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
if (src == ui.getAcPlSlider())
{
int n = playlist.getPlaylistSize();
float dx = (100 - ui.getAcPlSlider().getValue()) / 100.0f;
int index = (int) (dx * (n - 1));
if (index != topIndex)
{
topIndex = index;
paintList();
}
}
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e)
{
final ActionEvent evt = e;
new Thread("PlaylistUIActionEvent")
{
public void run()
{
processActionEvent(evt);
}
}.start();
}
/**
* Process action event.
* @param e
*/
public void processActionEvent(ActionEvent e)
{
String cmd = e.getActionCommand();
log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
int n = playlist.getPlaylistSize();
if (cmd.equals(PlayerActionEvent.ACPLUP))
{
topIndex--;
if (topIndex < 0) topIndex = 0;
resetScrollBar();
paintList();
}
else if (cmd.equals(PlayerActionEvent.ACPLDOWN))
{
topIndex++;
if (topIndex > n - 1) topIndex = n - 1;
resetScrollBar();
paintList();
}
else if (cmd.equals(PlayerActionEvent.ACPLADDPOPUP))
{
ui.getAcPlAdd().setVisible(false);
ui.getAcPlAddPopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVEPOPUP))
{
ui.getAcPlRemove().setVisible(false);
ui.getAcPlRemovePopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLSELPOPUP))
{
ui.getAcPlSelect().setVisible(false);
ui.getAcPlSelectPopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLMISCPOPUP))
{
ui.getAcPlMisc().setVisible(false);
ui.getAcPlMiscPopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLLISTPOPUP))
{
ui.getAcPlList().setVisible(false);
ui.getAcPlListPopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLINFO))
{
popupFileInfo();
}
else if (cmd.equals(PlayerActionEvent.ACPLPLAY))
{
int n0 = playlist.getPlaylistSize();
PlaylistItem pli = null;
for (int i = n0 - 1; i >= 0; i--)
{
pli = playlist.getItemAt(i);
if (pli.isSelected()) break;
}
// Play.
if ((pli != null) && (pli.getTagInfo() != null))
{
player.pressStop();
player.setCurrentSong(pli);
playlist.setCursor(playlist.getIndex(pli));
player.pressStart();
}
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVE))
{
delSelectedItems();
}
else if (cmd.equals(PlayerActionEvent.ACPLADDFILE))
{
ui.getAcPlAddPopup().setVisible(false);
ui.getAcPlAdd().setVisible(true);
File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.OPEN, true, config.getExtensions(), ui.getResource("playlist.popup.add.file"), new File(config.getLastDir()));
if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
addFiles(file);
}
else if (cmd.equals(PlayerActionEvent.ACPLADDURL))
{
ui.getAcPlAddPopup().setVisible(false);
ui.getAcPlAdd().setVisible(true);
UrlDialog UD = new UrlDialog(config.getTopParent(), ui.getResource("playlist.popup.add.url"), player.getLoader().getLocation().x, player.getLoader().getLocation().y + player.getHeight(), null);
UD.show();
if (UD.getFile() != null)
{
PlaylistItem pli = new PlaylistItem(UD.getFile(), UD.getURL(), -1, false);
playlist.appendItem(pli);
resetScrollBar();
repaint();
}
}
else if (cmd.equals(PlayerActionEvent.ACPLADDDIR))
{
ui.getAcPlAddPopup().setVisible(false);
ui.getAcPlAdd().setVisible(true);
File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.DIRECTORY, false, "", ui.getResource("playlist.popup.add.dir"), new File(config.getLastDir()));
if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
if (file == null || !file[0].isDirectory()) return;
// TODO - add message box for wrong filename
addDir(file[0]);
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVEALL))
{
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
delAllItems();
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVESEL))
{
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
delSelectedItems();
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVEMISC))
{
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVECROP))
{
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLSELALL))
{
ui.getAcPlSelectPopup().setVisible(false);
ui.getAcPlSelect().setVisible(true);
selFunctions(1);
}
else if (cmd.equals(PlayerActionEvent.ACPLSELINV))
{
ui.getAcPlSelectPopup().setVisible(false);
ui.getAcPlSelect().setVisible(true);
selFunctions(-1);
}
else if (cmd.equals(PlayerActionEvent.ACPLSELZERO))
{
ui.getAcPlSelectPopup().setVisible(false);
ui.getAcPlSelect().setVisible(true);
selFunctions(0);
}
else if (cmd.equals(PlayerActionEvent.ACPLMISCOPTS))
{
ui.getAcPlMiscPopup().setVisible(false);
ui.getAcPlMisc().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLMISCFILE))
{
ui.getAcPlMiscPopup().setVisible(false);
ui.getAcPlMisc().setVisible(true);
popupFileInfo();
}
else if (cmd.equals(PlayerActionEvent.ACPLMISCSORT))
{
ui.getAcPlMiscPopup().setVisible(false);
ui.getAcPlMisc().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLLISTLOAD))
{
ui.getAcPlListPopup().setVisible(false);
ui.getAcPlList().setVisible(true);
File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.OPEN, true, config.getExtensions(), ui.getResource("playlist.popup.list.load"), new File(config.getLastDir()));
if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
if ((file != null) && (file[0] != null))
{
String fsFile = file[0].getName();
if ((fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.m3u"))) || (fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.pls"))))
{
if (player.loadPlaylist(config.getLastDir() + fsFile))
{
config.setPlaylistFilename(config.getLastDir() + fsFile);
playlist.begin();
playlist.setCursor(-1);
// TODO
topIndex = 0;
}
resetScrollBar();
repaint();
}
}
}
else if (cmd.equals(PlayerActionEvent.ACPLLISTSAVE))
{
ui.getAcPlListPopup().setVisible(false);
ui.getAcPlList().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLLISTNEW))
{
ui.getAcPlListPopup().setVisible(false);
ui.getAcPlList().setVisible(true);
// TODO
}
}
/**
* Display file info.
*/
public void popupFileInfo()
{
int n0 = playlist.getPlaylistSize();
PlaylistItem pli = null;
for (int i = n0 - 1; i >= 0; i--)
{
pli = playlist.getItemAt(i);
if (pli.isSelected()) break;
}
// Display Tag Info.
if (pli != null)
{
TagInfo taginfo = pli.getTagInfo();
TagInfoFactory factory = TagInfoFactory.getInstance();
TagInfoDialog dialog = factory.getTagInfoDialog(taginfo);
dialog.setLocation(player.getLoader().getLocation().x, player.getLoader().getLocation().y + player.getHeight());
dialog.show();
}
}
/**
* Selection operation in pledit window
* @param mode -1 : inverse selected items, 0 : select none, 1 : select all
*/
private void selFunctions(int mode)
{
int n0 = playlist.getPlaylistSize();
if (n0 == 0) return;
for (int i = 0; i < n0; i++)
{
PlaylistItem pli = playlist.getItemAt(i);
if (pli == null) break;
if (mode == -1)
{ // inverse selection
pli.setSelected(!pli.isSelected());
}
else if (mode == 0)
{ // select none
pli.setSelected(false);
}
else if (mode == 1)
{ // select all
pli.setSelected(true);
}
}
repaint();
}
/**
* Remove all items in playlist.
*/
private void delAllItems()
{
int n0 = playlist.getPlaylistSize();
if (n0 == 0) return;
playlist.removeAllItems();
topIndex = 0;
ui.getAcPlSlider().setValue(100);
repaint();
}
/**
* Remove selected items in playlist.
*/
private void delSelectedItems()
{
int n0 = playlist.getPlaylistSize();
boolean brepaint = false;
for (int i = n0 - 1; i >= 0; i--)
{
if (playlist.getItemAt(i).isSelected())
{
playlist.removeItemAt(i);
brepaint = true;
}
}
if (brepaint)
{
int n = playlist.getPlaylistSize();
if (topIndex >= n) topIndex = n - 1;
if (topIndex < 0) topIndex = 0;
resetScrollBar();
repaint();
}
}
/**
* Add file(s) to playlist.
* @param file
*/
public void addFiles(File[] file)
{
if (file != null)
{
for (int i = 0; i < file.length; i++)
{
String fsFile = file[i].getName();
if ((!fsFile.toLowerCase().endsWith(ui.getResource("skin.extension"))) && (!fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.m3u"))) && (!fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.pls"))))
{
PlaylistItem pli = new PlaylistItem(fsFile, file[i].getAbsolutePath(), -1, true);
playlist.appendItem(pli);
resetScrollBar();
repaint();
}
}
}
}
/**
* Handle mouse clicks on playlist.
* @param evt
*/
protected void handleMouseClick(MouseEvent evt)
{
int x = evt.getX();
int y = evt.getY();
ui.getAcPlAddPopup().setVisible(false);
ui.getAcPlAdd().setVisible(true);
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
ui.getAcPlSelectPopup().setVisible(false);
ui.getAcPlSelect().setVisible(true);
ui.getAcPlMiscPopup().setVisible(false);
ui.getAcPlMisc().setVisible(true);
ui.getAcPlListPopup().setVisible(false);
ui.getAcPlList().setVisible(true);
// Check select action
if (ui.getPlaylistPanel().isInSelectArea(x, y))
{
int index = getIndex(y);
if (index != -1)
{
// PopUp
if (javax.swing.SwingUtilities.isRightMouseButton(evt))
{
if (fipopup != null) fipopup.show(this, x, y);
}
else
{
PlaylistItem pli = playlist.getItemAt(index);
if (pli != null)
{
pli.setSelected(!pli.isSelected());
if ((evt.getClickCount() == 2) && (evt.getModifiers() == MouseEvent.BUTTON1_MASK))
{
player.pressStop();
player.setCurrentSong(pli);
playlist.setCursor(index);
player.pressStart();
}
}
}
repaint();
}
}
}
/**
* Process Drag&Drop
* @param data
*/
public void processDnD(Object data)
{
log.debug("Playlist DnD");
// Looking for files to drop.
if (data instanceof List)
{
List al = (List) data;
if ((al != null) && (al.size() > 0))
{
ArrayList fileList = new ArrayList();
ArrayList folderList = new ArrayList();
ListIterator li = al.listIterator();
while (li.hasNext())
{
File f = (File) li.next();
if ((f.exists()) && (f.canRead()))
{
if (f.isFile()) fileList.add(f);
else if (f.isDirectory()) folderList.add(f);
}
}
addFiles(fileList);
addDirs(folderList);
}
}
else if (data instanceof String)
{
String files = (String) data;
if ((files.length() > 0))
{
ArrayList fileList = new ArrayList();
ArrayList folderList = new ArrayList();
StringTokenizer st = new StringTokenizer(files, System.getProperty("line.separator"));
// Transfer files dropped.
while (st.hasMoreTokens())
{
String path = st.nextToken();
if (path.startsWith("file://"))
{
path = path.substring(7, path.length());
if (path.endsWith("\r")) path = path.substring(0, (path.length() - 1));
}
File f = new File(path);
if ((f.exists()) && (f.canRead()))
{
if (f.isFile()) fileList.add(f);
else if (f.isDirectory()) folderList.add(f);
}
}
addFiles(fileList);
addDirs(folderList);
}
}
else
{
log.info("Unknown dropped objects");
}
}
/**
* Add files to playlistUI.
* @param fileList
*/
public void addFiles(List fileList)
{
if (fileList.size() > 0)
{
File[] file = (File[]) fileList.toArray(new File[fileList.size()]);
addFiles(file);
}
}
/**
* Add directories to playlistUI.
* @param folderList
*/
public void addDirs(List folderList)
{
if (folderList.size() > 0)
{
ListIterator it = folderList.listIterator();
while (it.hasNext())
{
addDir((File) it.next());
}
}
}
/**
* Compute slider value.
*/
private void resetScrollBar()
{
int n = playlist.getPlaylistSize();
float dx = (n < 1) ? 0 : ((float) topIndex / (n - 1)) * (100);
ui.getAcPlSlider().setValue(100 - (int) dx);
}
public void paintList()
{
if (!isVisible()) return;
else repaint();
}
/* (non-Javadoc)
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
public void paintComponent(Graphics g)
{
ui.getPlaylistPanel().paintBackground(g);
ui.getPlaylistPanel().paintList(g);
}
/**
* Add all files under this directory to play list.
* @param fsFile
*/
private void addDir(File fsFile)
{
// Put all music file extension in a Vector
String ext = config.getExtensions();
StringTokenizer st = new StringTokenizer(ext, ", ");
if (exts == null)
{
exts = new Vector();
while (st.hasMoreTokens())
{
exts.add("." + st.nextElement());
}
}
// recursive
Thread addThread = new AddThread(fsFile);
addThread.start();
// Refresh thread
Thread refresh = new Thread("Refresh")
{
public void run()
{
while (isSearching)
{
resetScrollBar();
repaint();
try
{
Thread.sleep(4000);
}
catch (Exception ex)
{
}
}
}
};
refresh.start();
}
class AddThread extends Thread
{
private File fsFile;
public AddThread(File fsFile)
{
super("Add");
this.fsFile = fsFile;
}
public void run()
{
isSearching = true;
addMusicRecursive(fsFile, 0);
isSearching = false;
resetScrollBar();
repaint();
}
}
private void addMusicRecursive(File rootDir, int depth)
{
// We do not want waste time
if (rootDir == null || depth > MAXDEPTH) return;
String[] list = rootDir.list();
if (list == null) return;
for (int i = 0; i < list.length; i++)
{
File ff = new File(rootDir, list[i]);
if (ff.isDirectory()) addMusicRecursive(ff, depth + 1);
else
{
if (isMusicFile(list[i]))
{
PlaylistItem pli = new PlaylistItem(list[i], rootDir + File.separator + list[i], -1, true);
playlist.appendItem(pli);
}
}
}
}
private boolean isMusicFile(String ff)
{
int sz = exts.size();
for (int i = 0; i < sz; i++)
{
String ext = exts.elementAt(i).toString().toLowerCase();
// TODO : Improve
if (ext.equalsIgnoreCase(".wsz") || ext.equalsIgnoreCase(".m3u") || ext.equalsIgnoreCase(".pls")) continue;
if (ff.toLowerCase().endsWith(exts.elementAt(i).toString().toLowerCase())) return true;
}
return false;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/playlist/ui/PlaylistUI.java | Java | asf20 | 30,384 |
/*
* SpectrumTimeAnalyzer.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.visual.ui;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import javax.sound.sampled.SourceDataLine;
import javax.swing.JPanel;
import javazoom.jlgui.player.amp.skin.AbsoluteConstraints;
import kj.dsp.KJDigitalSignalProcessingAudioDataConsumer;
import kj.dsp.KJDigitalSignalProcessor;
import kj.dsp.KJFFT;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SpectrumTimeAnalyzer extends JPanel implements KJDigitalSignalProcessor
{
private static Log log = LogFactory.getLog(SpectrumTimeAnalyzer.class);
public static final int DISPLAY_MODE_SCOPE = 0;
public static final int DISPLAY_MODE_SPECTRUM_ANALYSER = 1;
public static final int DISPLAY_MODE_OFF = 2;
public static final int DEFAULT_WIDTH = 256;
public static final int DEFAULT_HEIGHT = 128;
public static final int DEFAULT_FPS = 50;
public static final int DEFAULT_SPECTRUM_ANALYSER_FFT_SAMPLE_SIZE = 512;
public static final int DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT = 19;
public static final float DEFAULT_SPECTRUM_ANALYSER_DECAY = 0.05f;
public static final int DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY = 20;
public static final float DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO = 0.4f;
public static final float DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE = 0.1f;
public static final float MIN_SPECTRUM_ANALYSER_DECAY = 0.02f;
public static final float MAX_SPECTRUM_ANALYSER_DECAY = 0.08f;
public static final Color DEFAULT_BACKGROUND_COLOR = new Color(0, 0, 128);
public static final Color DEFAULT_SCOPE_COLOR = new Color(255, 192, 0);
public static final float DEFAULT_VU_METER_DECAY = 0.02f;
private Image bi;
private int displayMode = DISPLAY_MODE_SCOPE;
private Color scopeColor = DEFAULT_SCOPE_COLOR;
private Color[] spectrumAnalyserColors = getDefaultSpectrumAnalyserColors();
private KJDigitalSignalProcessingAudioDataConsumer dsp = null;
private boolean dspStarted = false;
private Color peakColor = null;
private int[] peaks = new int[DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT];
private int[] peaksDelay = new int[DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT];
private int peakDelay = DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY;
private boolean peaksEnabled = true;
private List visColors = null;
private int barOffset = 1;
private int width;
private int height;
private int height_2;
// -- Spectrum analyser variables.
private KJFFT fft;
private float[] old_FFT;
private int saFFTSampleSize;
private int saBands;
private float saColorScale;
private float saMultiplier;
private float saDecay = DEFAULT_SPECTRUM_ANALYSER_DECAY;
private float sad;
private SourceDataLine m_line = null;
// -- VU Meter
private float oldLeft;
private float oldRight;
// private float vuAverage;
// private float vuSamples;
private float vuDecay = DEFAULT_VU_METER_DECAY;
private float vuColorScale;
// -- FPS calulations.
private long lfu = 0;
private int fc = 0;
private int fps = DEFAULT_FPS;
private boolean showFPS = false;
private AbsoluteConstraints constraints = null;
// private Runnable PAINT_SYNCHRONIZER = new AWTPaintSynchronizer();
public SpectrumTimeAnalyzer()
{
setOpaque(false);
initialize();
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
public boolean isPeaksEnabled()
{
return peaksEnabled;
}
public void setPeaksEnabled(boolean peaksEnabled)
{
this.peaksEnabled = peaksEnabled;
}
public int getFps()
{
return fps;
}
public void setFps(int fps)
{
this.fps = fps;
}
/**
* Starts DSP.
* @param line
*/
public void startDSP(SourceDataLine line)
{
if (displayMode == DISPLAY_MODE_OFF) return;
if (line != null) m_line = line;
if (dsp == null)
{
dsp = new KJDigitalSignalProcessingAudioDataConsumer(2048, fps);
dsp.add(this);
}
if ((dsp != null) && (m_line != null))
{
if (dspStarted == true)
{
stopDSP();
}
dsp.start(m_line);
dspStarted = true;
log.debug("DSP started");
}
}
/**
* Stop DSP.
*/
public void stopDSP()
{
if (dsp != null)
{
dsp.stop();
dspStarted = false;
log.debug("DSP stopped");
}
}
/**
* Close DSP
*/
public void closeDSP()
{
if (dsp != null)
{
stopDSP();
dsp = null;
log.debug("DSP closed");
}
}
/**
* Setup DSP.
* @param line
*/
public void setupDSP(SourceDataLine line)
{
if (dsp != null)
{
int channels = line.getFormat().getChannels();
if (channels == 1) dsp.setChannelMode(KJDigitalSignalProcessingAudioDataConsumer.CHANNEL_MODE_MONO);
else dsp.setChannelMode(KJDigitalSignalProcessingAudioDataConsumer.CHANNEL_MODE_STEREO);
int bits = line.getFormat().getSampleSizeInBits();
if (bits == 8) dsp.setSampleType(KJDigitalSignalProcessingAudioDataConsumer.SAMPLE_TYPE_EIGHT_BIT);
else dsp.setSampleType(KJDigitalSignalProcessingAudioDataConsumer.SAMPLE_TYPE_SIXTEEN_BIT);
}
}
/**
* Write PCM data to DSP.
* @param pcmdata
*/
public void writeDSP(byte[] pcmdata)
{
if ((dsp != null) && (dspStarted == true)) dsp.writeAudioData(pcmdata);
}
/**
* Return DSP.
* @return
*/
public KJDigitalSignalProcessingAudioDataConsumer getDSP()
{
return dsp;
}
/**
* Set visual colors from skin.
* @param viscolor
*/
public void setVisColor(String viscolor)
{
ArrayList visColors = new ArrayList();
viscolor = viscolor.toLowerCase();
ByteArrayInputStream in = new ByteArrayInputStream(viscolor.getBytes());
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
try
{
String line = null;
while ((line = bin.readLine()) != null)
{
visColors.add(getColor(line));
}
Color[] colors = new Color[visColors.size()];
visColors.toArray(colors);
Color[] specColors = new Color[15];
System.arraycopy(colors, 2, specColors, 0, 15);
List specList = Arrays.asList(specColors);
Collections.reverse(specList);
specColors = (Color[]) specList.toArray(specColors);
setSpectrumAnalyserColors(specColors);
setBackground((Color) visColors.get(0));
if (visColors.size()>23) setPeakColor((Color) visColors.get(23));
if (visColors.size()>18) setScopeColor((Color) visColors.get(18));
}
catch (IOException ex)
{
log.warn("Cannot parse viscolors", ex);
}
finally
{
try
{
if (bin != null) bin.close();
}
catch (IOException e)
{
}
}
}
/**
* Set visual peak color.
* @param c
*/
public void setPeakColor(Color c)
{
peakColor = c;
}
/**
* Set peak falloff delay.
* @param framestowait
*/
public void setPeakDelay(int framestowait)
{
int min = (int) Math.round((DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO - DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE) * fps);
int max = (int) Math.round((DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO + DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE) * fps);
if ((framestowait >= min) && (framestowait <= max))
{
peakDelay = framestowait;
}
else
{
peakDelay = (int) Math.round(DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO * fps);
}
}
/**
* Return peak falloff delay
* @return int framestowait
*/
public int getPeakDelay()
{
return peakDelay;
}
/**
* Convert string to color.
* @param linecolor
* @return
*/
public Color getColor(String linecolor)
{
Color color = Color.BLACK;
StringTokenizer st = new StringTokenizer(linecolor, ",");
int red = 0, green = 0, blue = 0;
try
{
if (st.hasMoreTokens()) red = Integer.parseInt(st.nextToken().trim());
if (st.hasMoreTokens()) green = Integer.parseInt(st.nextToken().trim());
if (st.hasMoreTokens())
{
String blueStr = st.nextToken().trim();
if (blueStr.length() > 3) blueStr = (blueStr.substring(0, 3)).trim();
blue = Integer.parseInt(blueStr);
}
color = new Color(red, green, blue);
}
catch (NumberFormatException e)
{
log.debug("Cannot parse viscolor : "+e.getMessage());
}
return color;
}
private void computeColorScale()
{
saColorScale = ((float) spectrumAnalyserColors.length / height) * barOffset * 1.0f;
vuColorScale = ((float) spectrumAnalyserColors.length / (width - 32)) * 2.0f;
}
private void computeSAMultiplier()
{
saMultiplier = (saFFTSampleSize / 2) / saBands;
}
private void drawScope(Graphics pGrp, float[] pSample)
{
pGrp.setColor(scopeColor);
int wLas = (int) (pSample[0] * (float) height_2) + height_2;
int wSt = 2;
for (int a = wSt, c = 0; c < width; a += wSt, c++)
{
int wAs = (int) (pSample[a] * (float) height_2) + height_2;
pGrp.drawLine(c, wLas, c + 1, wAs);
wLas = wAs;
}
}
private void drawSpectrumAnalyser(Graphics pGrp, float[] pSample, float pFrrh)
{
float c = 0;
float[] wFFT = fft.calculate(pSample);
float wSadfrr = (saDecay * pFrrh);
float wBw = ((float) width / (float) saBands);
for (int a = 0, bd = 0; bd < saBands; a += saMultiplier, bd++)
{
float wFs = 0;
// -- Average out nearest bands.
for (int b = 0; b < saMultiplier; b++)
{
wFs += wFFT[a + b];
}
// -- Log filter.
wFs = (wFs * (float) Math.log(bd + 2));
if (wFs > 1.0f)
{
wFs = 1.0f;
}
// -- Compute SA decay...
if (wFs >= (old_FFT[a] - wSadfrr))
{
old_FFT[a] = wFs;
}
else
{
old_FFT[a] -= wSadfrr;
if (old_FFT[a] < 0)
{
old_FFT[a] = 0;
}
wFs = old_FFT[a];
}
drawSpectrumAnalyserBar(pGrp, (int) c, height, (int) wBw - 1, (int) (wFs * height), bd);
c += wBw;
}
}
private void drawVUMeter(Graphics pGrp, float[] pLeft, float[] pRight, float pFrrh)
{
if (displayMode == DISPLAY_MODE_OFF) return;
float wLeft = 0.0f;
float wRight = 0.0f;
float wSadfrr = (vuDecay * pFrrh);
for (int a = 0; a < pLeft.length; a++)
{
wLeft += Math.abs(pLeft[a]);
wRight += Math.abs(pRight[a]);
}
wLeft = ((wLeft * 2.0f) / (float) pLeft.length);
wRight = ((wRight * 2.0f) / (float) pRight.length);
if (wLeft > 1.0f)
{
wLeft = 1.0f;
}
if (wRight > 1.0f)
{
wRight = 1.0f;
}
// vuAverage += ( ( wLeft + wRight ) / 2.0f );
// vuSamples++;
//
// if ( vuSamples > 128 ) {
// vuSamples /= 2.0f;
// vuAverage /= 2.0f;
// }
if (wLeft >= (oldLeft - wSadfrr))
{
oldLeft = wLeft;
}
else
{
oldLeft -= wSadfrr;
if (oldLeft < 0)
{
oldLeft = 0;
}
}
if (wRight >= (oldRight - wSadfrr))
{
oldRight = wRight;
}
else
{
oldRight -= wSadfrr;
if (oldRight < 0)
{
oldRight = 0;
}
}
int wHeight = (height >> 1) - 24;
drawVolumeMeterBar(pGrp, 16, 16, (int) (oldLeft * (float) (width - 32)), wHeight);
// drawVolumeMeterBar( pGrp, 16, wHeight + 22, (int)( ( vuAverage / vuSamples ) * (float)( width - 32 ) ), 4 );
drawVolumeMeterBar(pGrp, 16, wHeight + 32, (int) (oldRight * (float) (width - 32)), wHeight);
// pGrp.fillRect( 16, 16, (int)( oldLeft * (float)( width - 32 ) ), wHeight );
// pGrp.fillRect( 16, 64, (int)( oldRight * (float)( width - 32 ) ), wHeight );
}
private void drawSpectrumAnalyserBar(Graphics pGraphics, int pX, int pY, int pWidth, int pHeight, int band)
{
float c = 0;
for (int a = pY; a >= pY - pHeight; a -= barOffset)
{
c += saColorScale;
if (c < spectrumAnalyserColors.length)
{
pGraphics.setColor(spectrumAnalyserColors[(int) c]);
}
pGraphics.fillRect(pX, a, pWidth, 1);
}
if ((peakColor != null) && (peaksEnabled == true))
{
pGraphics.setColor(peakColor);
if (pHeight > peaks[band])
{
peaks[band] = pHeight;
peaksDelay[band] = peakDelay;
}
else
{
peaksDelay[band]--;
if (peaksDelay[band] < 0) peaks[band]--;
if (peaks[band] < 0) peaks[band] = 0;
}
pGraphics.fillRect(pX, pY - peaks[band], pWidth, 1);
}
}
private void drawVolumeMeterBar(Graphics pGraphics, int pX, int pY, int pWidth, int pHeight)
{
float c = 0;
for (int a = pX; a <= pX + pWidth; a += 2)
{
c += vuColorScale;
if (c < 256.0f)
{
pGraphics.setColor(spectrumAnalyserColors[(int) c]);
}
pGraphics.fillRect(a, pY, 1, pHeight);
}
}
private synchronized Image getDoubleBuffer()
{
if (bi == null || (bi.getWidth(null) != getSize().width || bi.getHeight(null) != getSize().height))
{
width = getSize().width;
height = getSize().height;
height_2 = height >> 1;
computeColorScale();
bi = getGraphicsConfiguration().createCompatibleVolatileImage(width, height);
}
return bi;
}
public static Color[] getDefaultSpectrumAnalyserColors()
{
Color[] wColors = new Color[256];
for (int a = 0; a < 128; a++)
{
wColors[a] = new Color(0, (a >> 1) + 192, 0);
}
for (int a = 0; a < 64; a++)
{
wColors[a + 128] = new Color(a << 2, 255, 0);
}
for (int a = 0; a < 64; a++)
{
wColors[a + 192] = new Color(255, 255 - (a << 2), 0);
}
return wColors;
}
/**
* @return Returns the current display mode, DISPLAY_MODE_SCOPE or DISPLAY_MODE_SPECTRUM_ANALYSER.
*/
public int getDisplayMode()
{
return displayMode;
}
/**
* @return Returns the current number of bands displayed by the spectrum analyser.
*/
public int getSpectrumAnalyserBandCount()
{
return saBands;
}
/**
* @return Returns the decay rate of the spectrum analyser's bands.
*/
public float getSpectrumAnalyserDecay()
{
return saDecay;
}
/**
* @return Returns the color the scope is rendered in.
*/
public Color getScopeColor()
{
return scopeColor;
}
/**
* @return Returns the color scale used to render the spectrum analyser bars.
*/
public Color[] getSpectrumAnalyserColors()
{
return spectrumAnalyserColors;
}
private void initialize()
{
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
setBackground(DEFAULT_BACKGROUND_COLOR);
prepareDisplayToggleListener();
setSpectrumAnalyserBandCount(DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT);
setSpectrumAnalyserFFTSampleSize(DEFAULT_SPECTRUM_ANALYSER_FFT_SAMPLE_SIZE);
}
/**
* @return Returns 'true' if "Frames Per Second" are being calculated and displayed.
*/
public boolean isShowingFPS()
{
return showFPS;
}
public void paintComponent(Graphics pGraphics)
{
if (displayMode == DISPLAY_MODE_OFF) return;
if (dspStarted)
{
pGraphics.drawImage(getDoubleBuffer(), 0, 0, null);
}
else
{
super.paintComponent(pGraphics);
}
}
private void prepareDisplayToggleListener()
{
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent pEvent)
{
if (pEvent.getButton() == MouseEvent.BUTTON1)
{
if (displayMode + 1 > 1)
{
displayMode = 0;
}
else
{
displayMode++;
}
}
}
});
}
/* (non-Javadoc)
* @see kj.dsp.KJDigitalSignalProcessor#process(float[], float[], float)
*/
public synchronized void process(float[] pLeft, float[] pRight, float pFrameRateRatioHint)
{
if (displayMode == DISPLAY_MODE_OFF) return;
Graphics wGrp = getDoubleBuffer().getGraphics();
wGrp.setColor(getBackground());
wGrp.fillRect(0, 0, getSize().width, getSize().height);
switch (displayMode)
{
case DISPLAY_MODE_SCOPE:
drawScope(wGrp, stereoMerge(pLeft, pRight));
break;
case DISPLAY_MODE_SPECTRUM_ANALYSER:
drawSpectrumAnalyser(wGrp, stereoMerge(pLeft, pRight), pFrameRateRatioHint);
break;
case DISPLAY_MODE_OFF:
drawVUMeter(wGrp, pLeft, pRight, pFrameRateRatioHint);
break;
}
// -- Show FPS if necessary.
if (showFPS)
{
// -- Calculate FPS.
if (System.currentTimeMillis() >= lfu + 1000)
{
lfu = System.currentTimeMillis();
fps = fc;
fc = 0;
}
fc++;
wGrp.setColor(Color.yellow);
wGrp.drawString("FPS: " + fps + " (FRRH: " + pFrameRateRatioHint + ")", 0, height - 1);
}
if (getGraphics() != null) getGraphics().drawImage(getDoubleBuffer(), 0, 0, null);
// repaint();
// try {
// EventQueue.invokeLater( new AWTPaintSynchronizer() );
// } catch ( Exception pEx ) {
// // -- Ignore exception.
// pEx.printStackTrace();
// }
}
/**
* Sets the current display mode.
*
* @param pMode Must be either DISPLAY_MODE_SCOPE or DISPLAY_MODE_SPECTRUM_ANALYSER.
*/
public synchronized void setDisplayMode(int pMode)
{
displayMode = pMode;
}
/**
* Sets the color of the scope.
*
* @param pColor
*/
public synchronized void setScopeColor(Color pColor)
{
scopeColor = pColor;
}
/**
* When 'true' is passed as a parameter, will overlay the "Frames Per Seconds"
* achieved by the component.
*
* @param pState
*/
public synchronized void setShowFPS(boolean pState)
{
showFPS = pState;
}
/**
* Sets the numbers of bands rendered by the spectrum analyser.
*
* @param pCount Cannot be more than half the "FFT sample size".
*/
public synchronized void setSpectrumAnalyserBandCount(int pCount)
{
saBands = pCount;
peaks = new int[saBands];
peaksDelay = new int[saBands];
computeSAMultiplier();
}
/**
* Sets the spectrum analyser band decay rate.
*
* @param pDecay Must be a number between 0.0 and 1.0 exclusive.
*/
public synchronized void setSpectrumAnalyserDecay(float pDecay)
{
if ((pDecay >= MIN_SPECTRUM_ANALYSER_DECAY) && (pDecay <= MAX_SPECTRUM_ANALYSER_DECAY))
{
saDecay = pDecay;
}
else saDecay = DEFAULT_SPECTRUM_ANALYSER_DECAY;
}
/**
* Sets the spectrum analyser color scale.
*
* @param pColors Any amount of colors may be used. Must not be null.
*/
public synchronized void setSpectrumAnalyserColors(Color[] pColors)
{
spectrumAnalyserColors = pColors;
computeColorScale();
}
/**
* Sets the FFT sample size to be just for calculating the spectrum analyser
* values. The default is 512.
*
* @param pSize Cannot be more than the size of the sample provided by the DSP.
*/
public synchronized void setSpectrumAnalyserFFTSampleSize(int pSize)
{
saFFTSampleSize = pSize;
fft = new KJFFT(saFFTSampleSize);
old_FFT = new float[saFFTSampleSize];
computeSAMultiplier();
}
private float[] stereoMerge(float[] pLeft, float[] pRight)
{
for (int a = 0; a < pLeft.length; a++)
{
pLeft[a] = (pLeft[a] + pRight[a]) / 2.0f;
}
return pLeft;
}
/*public void update(Graphics pGraphics)
{
// -- Prevent AWT from clearing background.
paint(pGraphics);
}*/
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/visual/ui/SpectrumTimeAnalyzer.java | Java | asf20 | 24,423 |
/*
* Loader.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp;
import java.awt.Point;
public interface Loader
{
public void loaded();
public void close();
public void minimize();
public Point getLocation();
public void togglePlaylist(boolean enabled);
public void toggleEqualizer(boolean enabled);
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/src/javazoom/jlgui/player/amp/Loader.java | Java | asf20 | 1,329 |
SET JAVA_HOME=d:\java\jdk1.5.0
SET ANT_HOME=d:\java\ant1.6.1
SET PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
SET CLASSPATH=%ANT_HOME%\lib\crimson.jar;%ANT_HOME%\lib\jaxp.jar;%ANT_HOME%\lib\ant.jar | 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/jlgui3.0/setenv.bat | Batchfile | asf20 | 191 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package bean;
import java.beans.*;
import java.io.Serializable;
import javazoom.jlgui.basicplayer.BasicPlayer;
import javazoom.jlgui.*;
import java.io.File;
/**
*
* @author Robert Alvarado
*/
public class Music implements Serializable {
private BasicPlayer player = new BasicPlayer();
public void Play() throws Exception {
player.play();
}
public void AbrirFichero(String ruta) throws Exception {
player.open(new File(ruta));
}
public void Pausa() throws Exception {
player.pause();
}
public void Continuar() throws Exception {
player.resume();
}
public void Stop() throws Exception {
player.stop();
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/LIB/Musica/src/bean/Music.java | Java | asf20 | 821 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package bean;
import java.io.Serializable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.*;
import javax.swing.JLabel;
import javax.swing.Timer;
/**
*
* @author Robert Alvarado
*/
public class Reloj extends JLabel {
private Timer timer;
int tiempo = 0;
int tiempo2 = 0;
int tiempo3 = 0;
private String MSegundo = "00";
private String Segundo = "0";
private String Minuto = "0";
String Texto = "00:00:00";
public void actualizacion(final JLabel L) {
timer = new Timer(1, new ActionListener() {
public void actionPerformed(ActionEvent e) {
tiempo++;
MSegundo = Integer.toString(tiempo);
if (tiempo == 59) {
tiempo2++;
tiempo = 0;
Segundo = Integer.toString(tiempo2);
if (tiempo2 == 59) {
tiempo3++;
tiempo2 = 0;
Minuto = Integer.toString(tiempo3);
}
}
if (Integer.parseInt(Minuto) <= 9) {
Texto = "0" + Minuto + ":";
} else {
Texto = Minuto + ":";
}
if (Integer.parseInt(Segundo) <= 9) {
Texto = Texto + "0" + Segundo + ":";
} else {
Texto = Texto + Segundo + ":";
}
if (Integer.parseInt(MSegundo) <= 9) {
Texto = Texto + "0" + MSegundo;
} else {
Texto = Texto + MSegundo;
}
L.setText(Texto);
}
});
}
public void Parar() {
timer.stop();
}
public void Iniciar(){
timer.start();
}
public void Reiniciar(JLabel L){
this.Minuto = "0";
this.Segundo = "0";
this.MSegundo = "0";
tiempo = 0;
tiempo2 = 0;
tiempo3 = 0;
Texto = "00:00:00";
L.setText(Texto);
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Code/Reloj.java | Java | asf20 | 2,245 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package bean;
import java.beans.*;
import java.io.Serializable;
import javazoom.jlgui.basicplayer.BasicPlayer;
import javazoom.jlgui.*;
import java.io.File;
/**
*
* @author Robert Alvarado
*/
public class Music implements Serializable {
private BasicPlayer player = new BasicPlayer();
public void Play() throws Exception {
player.play();
}
public void AbrirFichero(String ruta) throws Exception {
player.open(new File(ruta));
}
public void Pausa() throws Exception {
player.pause();
}
public void Continuar() throws Exception {
player.resume();
}
public void Stop() throws Exception {
player.stop();
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Code/Music.java | Java | asf20 | 821 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package BD;
import bean.Conexion;
/**
*
* @author Robert Alvarado
*/
public class ConexionDAO {
public ConexionDAO() {
super();
Conexion.establecerPropiedadesConexion("org.postgresql.Driver", "jdbc:postgresql://localhost:5432/", "BD1-1", "postgres", "postgress");
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/BD/ConexionDAO.java | Java | asf20 | 402 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Controlador;
import Modelo.Jugador;
import Modelo.ModPartida;
import Vista.VistaPart;
import bean.Music;
import java.awt.Color;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import bean.Reloj;
/**
*
* @author USUARIO
*/
public class ContPartida {
private VistaPart VP;
private ModPartida M;
private Vector<JLabel> labeles = new Vector<JLabel>();
private Vector Palabras = new Vector();
private Reloj R = new Reloj();
Music Reproducion = new Music();
private int Nivel = 0;
ContPartida(VistaPart VP, ModPartida M, int Nivel) throws SQLException, Exception {
this.Reproducion.AbrirFichero("C:/Documents and Settings/Robert Alvarado/Escritorio/FINAL_COLOR/1-1-primer-proyecto/src/Musica/1.mp3");
this.Reproducion.Play();
this.VP = VP;
this.M = M;
this.VP.setVisible(true);
this.Nivel = Nivel + 1;
this.agregarVectLabel();
R.actualizacion(this.VP.getReloj());
this.IniciarPartida();
}
public void IniciarPartida() throws SQLException {
R.Parar();
R.Reiniciar(this.VP.getReloj());
R.Iniciar();
this.VP.HablitarRegistro(false);
this.M.setError(0);
this.M.setAcierto(0);
this.Imagenes();
if(this.Nivel == 1){
this.M.BuscarPalabra();
this.LimpiarLabeles();
}else if(this.Nivel == 2){
this.M.BuscarPalabra2();
this.LimpiarLabeles2();
this.LimpiarVacios(" ", " ");
}else{
this.M.BuscarPalabra3();
this.LimpiarLabeles2();
this.LimpiarVacios(" ", " ");
}
this.HabilitarTeclado(true);
this.VP.setMensaje("", false, Color.RED);
}
public Reloj getR() {
return R;
}
public void ContarError() {
this.M.ContarError();
this.Imagenes();
}
public void Salir() throws Exception{
this.Reproducion.Stop();
this.VP.dispose();
}
public void Imagenes() {
switch (this.M.getError()) {
case 0:
this.VP.setAhorcado("Imagenes/Aho00.gif");
break;
case 1:
this.VP.setAhorcado("Imagenes/Aho01.gif");
break;
case 2:
this.VP.setAhorcado("Imagenes/Aho0.gif");
break;
case 3:
this.VP.setAhorcado("Imagenes/Aho2.gif");
break;
case 4:
this.VP.setAhorcado("Imagenes/Aho3.gif");
break;
case 5:
this.VP.setAhorcado("Imagenes/Aho4.gif");
break;
case 6:
this.VP.setAhorcado("Imagenes/Aho5.gif");
break;
case 7:
this.VP.setAhorcado("Imagenes/Aho6.gif");
break;
case 8:
this.VP.setAhorcado("Imagenes/Aho7.gif");
break;
}
}
public void agregarVectLabel() {
this.labeles.add(this.VP.getjLabel1());
this.labeles.add(this.VP.getjLabel2());
this.labeles.add(this.VP.getjLabel3());
this.labeles.add(this.VP.getjLabel4());
this.labeles.add(this.VP.getjLabel5());
this.labeles.add(this.VP.getjLabel6());
this.labeles.add(this.VP.getjLabel7());
this.labeles.add(this.VP.getjLabel8());
this.labeles.add(this.VP.getjLabel9());
this.labeles.add(this.VP.getjLabel10());
this.labeles.add(this.VP.getjLabel11());
this.labeles.add(this.VP.getjLabel12());
this.labeles.add(this.VP.getjLabel13());
this.labeles.add(this.VP.getjLabel14());
this.labeles.add(this.VP.getjLabel15());
this.labeles.add(this.VP.getjLabel16());
this.labeles.add(this.VP.getjLabel17());
this.labeles.add(this.VP.getjLabel18());
this.labeles.add(this.VP.getjLabel19());
this.labeles.add(this.VP.getjLabel20());
this.labeles.add(this.VP.getjLabel21());
this.labeles.add(this.VP.getjLabel22());
this.labeles.add(this.VP.getjLabel23());
this.labeles.add(this.VP.getjLabel24());
this.labeles.add(this.VP.getjLabel25());
this.labeles.add(this.VP.getjLabel26());
this.labeles.add(this.VP.getjLabel27());
this.labeles.add(this.VP.getjLabel28());
this.labeles.add(this.VP.getjLabel29());
this.labeles.add(this.VP.getjLabel30());
this.labeles.add(this.VP.getjLabel31());
this.labeles.add(this.VP.getjLabel32());
this.labeles.add(this.VP.getjLabel33());
this.labeles.add(this.VP.getjLabel34());
this.labeles.add(this.VP.getjLabel35());
this.labeles.add(this.VP.getjLabel36());
this.labeles.add(this.VP.getjLabel37());
this.labeles.add(this.VP.getjLabel38());
this.labeles.add(this.VP.getjLabel39());
this.labeles.add(this.VP.getjLabel40());
this.labeles.add(this.VP.getjLabel41());
this.labeles.add(this.VP.getjLabel42());
this.labeles.add(this.VP.getjLabel43());
this.labeles.add(this.VP.getjLabel44());
this.labeles.add(this.VP.getjLabel45());
this.labeles.add(this.VP.getjLabel46());
this.labeles.add(this.VP.getjLabel47());
this.labeles.add(this.VP.getjLabel48());
this.labeles.add(this.VP.getjLabel49());
this.labeles.add(this.VP.getjLabel50());
this.labeles.add(this.VP.getjLabel51());
this.labeles.add(this.VP.getjLabel52());
this.labeles.add(this.VP.getjLabel53());
this.labeles.add(this.VP.getjLabel54());
this.labeles.add(this.VP.getjLabel55());
this.labeles.add(this.VP.getjLabel56());
this.labeles.add(this.VP.getjLabel57());
this.labeles.add(this.VP.getjLabel58());
this.labeles.add(this.VP.getjLabel59());
this.labeles.add(this.VP.getjLabel60());
this.labeles.add(this.VP.getjLabel61());
this.labeles.add(this.VP.getjLabel62());
this.labeles.add(this.VP.getjLabel63());
this.labeles.add(this.VP.getjLabel64());
this.labeles.add(this.VP.getjLabel65());
this.labeles.add(this.VP.getjLabel66());
this.labeles.add(this.VP.getjLabel67());
this.labeles.add(this.VP.getjLabel68());
this.labeles.add(this.VP.getjLabel69());
this.labeles.add(this.VP.getjLabel70());
this.labeles.add(this.VP.getjLabel71());
this.labeles.add(this.VP.getjLabel72());
this.labeles.add(this.VP.getjLabel73());
this.labeles.add(this.VP.getjLabel74());
this.labeles.add(this.VP.getjLabel75());
this.labeles.add(this.VP.getjLabel76());
this.labeles.add(this.VP.getjLabel77());
this.labeles.add(this.VP.getjLabel78());
this.labeles.add(this.VP.getjLabel79());
this.labeles.add(this.VP.getjLabel80());
this.labeles.add(this.VP.getjLabel81());
this.labeles.add(this.VP.getjLabel82());
this.labeles.add(this.VP.getjLabel83());
this.labeles.add(this.VP.getjLabel84());
this.labeles.add(this.VP.getjLabel85());
this.labeles.add(this.VP.getjLabel86());
this.labeles.add(this.VP.getjLabel87());
this.labeles.add(this.VP.getjLabel88());
this.labeles.add(this.VP.getjLabel89());
this.labeles.add(this.VP.getjLabel90());
this.labeles.add(this.VP.getjLabel91());
this.labeles.add(this.VP.getjLabel92());
this.labeles.add(this.VP.getjLabel93());
this.labeles.add(this.VP.getjLabel94());
this.labeles.add(this.VP.getjLabel95());
this.labeles.add(this.VP.getjLabel96());
this.labeles.add(this.VP.getjLabel97());
this.labeles.add(this.VP.getjLabel98());
this.labeles.add(this.VP.getjLabel99());
this.labeles.add(this.VP.getjLabel100());
this.labeles.add(this.VP.getjLabel101());
this.labeles.add(this.VP.getjLabel102());
this.labeles.add(this.VP.getjLabel103());
this.labeles.add(this.VP.getjLabel104());
this.labeles.add(this.VP.getjLabel105());
this.labeles.add(this.VP.getjLabel106());
this.labeles.add(this.VP.getjLabel107());
this.labeles.add(this.VP.getjLabel108());
this.labeles.add(this.VP.getjLabel109());
this.labeles.add(this.VP.getjLabel110());
this.labeles.add(this.VP.getjLabel111());
this.labeles.add(this.VP.getjLabel112());
this.labeles.add(this.VP.getjLabel113());
this.labeles.add(this.VP.getjLabel114());
this.labeles.add(this.VP.getjLabel115());
this.labeles.add(this.VP.getjLabel116());
this.labeles.add(this.VP.getjLabel117());
this.labeles.add(this.VP.getjLabel118());
this.labeles.add(this.VP.getjLabel119());
this.labeles.add(this.VP.getjLabel120());
this.labeles.add(this.VP.getjLabel121());
this.labeles.add(this.VP.getjLabel122());
this.labeles.add(this.VP.getjLabel123());
}
public void LimpiarLabeles() {
for (int a = 0; a < this.labeles.size(); a++) {
this.labeles.elementAt(a).setVisible(true);
}
for (int a = 0; a < this.M.getPalabraOri().size(); a++) {
this.labeles.elementAt(a).setText("_");
}
for (int a = (this.M.getPalabraOri().size()); a <= 122; a++) {
this.labeles.elementAt(a).setVisible(false);
}
}
public void LimpiarLabeles2() {
int P = 0;
for (int a = 0; a < this.M.getPalabraOri2().size(); a++) {
if (this.M.getPalabraOri2().elementAt(a) == " ") {
P++;
}
}
P++;
this.Palabras.clear();
String Frase = "";
for (int a = 0; a < this.M.getPalabraOri2().size(); a++) {
if (this.M.getPalabraOri2().elementAt(a).toString().charAt(0) == ' ') {
this.Palabras.add(Frase);
Frase = "";
} else if (a == this.M.getPalabraOri2().size() - 1) {
Frase = Frase + this.M.getPalabraOri2().elementAt(a);
this.Palabras.add(Frase);
Frase = "";
} else {
Frase = Frase + this.M.getPalabraOri2().elementAt(a);
}
}
for (int a = 0; a < this.labeles.size(); a++) {
this.labeles.elementAt(a).setVisible(true);
}
this.M.getPalabraOri2().clear();
String Frase2 = "";
int Fila1 = 33;
int Fila2 = 30;
int Fila3 = 30;
int Fila4 = 30;
boolean R1 = false;
boolean R2 = false;
boolean R3 = false;
boolean R4 = false;
for (int u = 0; u < this.Palabras.size(); u++) {
Frase2 = "";
Frase2 = this.Palabras.elementAt(u).toString();
if (Frase2.length() <= Fila1) {
Fila1 = Fila1 - Frase2.length() - 1;
for (int g = 0; g < Frase2.length(); g++) {
this.M.getPalabraOri2().add(Frase2.charAt(g));
}
this.M.getPalabraOri2().add(" ");
} else if (R1 == false) {
for (int y = 0; y < Fila1; y++) {
this.M.getPalabraOri2().add(" ");
this.labeles.elementAt(32 - y).setVisible(false);
}
if (Frase2.length() <= Fila2) {
Fila2 = Fila2 - Frase2.length() - 1;
for (int g = 0; g < Frase2.length(); g++) {
this.M.getPalabraOri2().add(Frase2.charAt(g));
}
this.M.getPalabraOri2().add(" ");
}
R1 = true;
} else if (Frase2.length() <= Fila2) {
Fila2 = Fila2 - Frase2.length() - 1;
for (int g = 0; g < Frase2.length(); g++) {
this.M.getPalabraOri2().add(Frase2.charAt(g));
}
this.M.getPalabraOri2().add(" ");
} else if (R2 == false) {
for (int y = 0; y < Fila2; y++) {
this.M.getPalabraOri2().add(" ");
this.labeles.elementAt(62 - y).setVisible(false);
}
if (Frase2.length() <= Fila3) {
Fila3 = Fila3 - Frase2.length() - 1;
for (int g = 0; g < Frase2.length(); g++) {
this.M.getPalabraOri2().add(Frase2.charAt(g));
}
this.M.getPalabraOri2().add(" ");
}
R2 = true;
} else if (Frase2.length() <= Fila3) {
Fila3 = Fila3 - Frase2.length() - 1;
for (int g = 0; g < Frase2.length(); g++) {
this.M.getPalabraOri2().add(Frase2.charAt(g));
}
this.M.getPalabraOri2().add(" ");
} else if (R3 == false) {
for (int y = 0; y < Fila3; y++) {
this.M.getPalabraOri2().add(" ");
this.labeles.elementAt(92 - y).setVisible(false);
}
if (Frase2.length() <= Fila4) {
Fila4 = Fila4 - Frase2.length() - 1;
for (int g = 0; g < Frase2.length(); g++) {
this.M.getPalabraOri2().add(Frase2.charAt(g));
}
this.M.getPalabraOri2().add(" ");
R3 = true;
}
} else if (Frase2.length() <= Fila4) {
Fila4 = Fila4 - Frase2.length() - 1;
for (int g = 0; g < Frase2.length(); g++) {
this.M.getPalabraOri2().add(Frase2.charAt(g));
}
this.M.getPalabraOri2().add(" ");
} else if (R4 == false) {
for (int y = 0; y < Fila4; y++) {
this.M.getPalabraOri2().add(" ");
this.labeles.elementAt(122 - y).setVisible(false);
}
R4 = true;
}
}
for (int a = 0; a < this.M.getPalabraOri2().size(); a++) {
this.labeles.elementAt(a).setText("_");
}
for (int a = (this.M.getPalabraOri2().size()); a <= 122; a++) {
this.labeles.elementAt(a).setVisible(false);
}
}
public void PonerLetra(char L, String L2,char L3){
if(this.Nivel == 1){
this.PonerLetra(L, L2);
}else{
this.PonerLetra2(L3, L2);
}
}
public void PonerLetra(char L, String L2) {
if (this.M.BuscarLetra(L)) {
for (int a = 0; a < this.M.getPalabraOri().size(); a++) {
for (int b = 0; b < this.M.getPosicion().size(); b++) {
if ((a + 1) == this.M.getPosicion().elementAt(b)) {
this.labeles.elementAt(a).setText(L2);
}
}
}
this.M.LimpiarPosicion();
if (this.M.Gano()) {
this.VP.setMensaje("GANASTE", true, Color.GREEN);
this.HabilitarTeclado(false);
this.M.setAcierto(0);
this.VP.HablitarRegistro(true);
this.R.Parar();
}
} else {
this.ContarError();
if (this.M.SeguirJugando() == false) {
this.HabilitarTeclado(false);
this.VP.setMensaje("PERDISTE", true, Color.RED);
this.M.setAcierto(0);
this.VP.HablitarRegistro(false);
this.R.Parar();
this.R.Reiniciar(this.VP.getReloj());
}
}
}
public void PonerLetra2(char L, String L2) {
if (this.M.BuscarLetra2(L)) {
for (int a = 0; a < this.M.getPalabraOri2().size(); a++) {
for (int b = 0; b < this.M.getPosicion().size(); b++) {
if ((a + 1) == this.M.getPosicion().elementAt(b)) {
this.labeles.elementAt(a).setText(L2);
}
}
}
this.M.LimpiarPosicion();
if (this.M.Gano2()) {
this.VP.setMensaje("GANASTE", true, Color.GREEN);
this.HabilitarTeclado(false);
this.M.setAcierto(0);
this.VP.HablitarRegistro(true);
this.R.Parar();
}
} else {
this.ContarError();
if (this.M.SeguirJugando() == false) {
this.HabilitarTeclado(false);
this.VP.setMensaje("PERDISTE", true, Color.RED);
this.M.setAcierto(0);
this.VP.HablitarRegistro(false);
this.R.Parar();
this.R.Reiniciar(this.VP.getReloj());
}
}
}
public void LimpiarVacios(String L, String L2) {
if (this.M.BuscarLetraV(L)) {
for (int a = 0; a < this.M.getPalabraOri2().size(); a++) {
for (int b = 0; b < this.M.getPosicion().size(); b++) {
if ((a + 1) == this.M.getPosicion().elementAt(b)) {
this.labeles.elementAt(a).setText(L2);
}
}
}
this.M.LimpiarPosicion();
if (this.M.Gano2()) {
this.VP.setMensaje("GANASTE", true, Color.GREEN);
this.HabilitarTeclado(false);
this.M.setAcierto(0);
this.VP.HablitarRegistro(true);
this.R.Parar();
}
} else {
this.ContarError();
if (this.M.SeguirJugando() == false) {
this.HabilitarTeclado(false);
this.VP.setMensaje("PERDISTE", true, Color.RED);
this.M.setAcierto(0);
this.VP.HablitarRegistro(false);
this.R.Parar();
this.R.Reiniciar(this.VP.getReloj());
}
}
}
public void GuardarPuntaje() {
if (!this.VP.getJNombre().getText().isEmpty()) {
Jugador J = new Jugador(this.VP.getJNombre().getText(), this.Nivel, this.VP.getReloj().getText());
this.R.Reiniciar(this.VP.getReloj());
this.VP.HablitarRegistro(false);
}else{
this.VP.MostrarMensaje();
}
}
public void HabilitarTeclado(boolean a) {
this.VP.setjButton1(a);
this.VP.setjButton2(a);
this.VP.setjButton3(a);
this.VP.setjButton4(a);
this.VP.setjButton5(a);
this.VP.setjButton6(a);
this.VP.setjButton7(a);
this.VP.setjButton8(a);
this.VP.setjButton9(a);
this.VP.setjButton10(a);
this.VP.setjButton11(a);
this.VP.setjButton12(a);
this.VP.setjButton13(a);
this.VP.setjButton14(a);
this.VP.setjButton15(a);
this.VP.setjButton16(a);
this.VP.setjButton17(a);
this.VP.setjButton18(a);
this.VP.setjButton19(a);
this.VP.setjButton20(a);
this.VP.setjButton21(a);
this.VP.setjButton22(a);
this.VP.setjButton23(a);
this.VP.setjButton24(a);
this.VP.setjButton25(a);
this.VP.setjButton26(a);
this.VP.setjButton27(a);
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Controlador/ContPartida.java | Java | asf20 | 19,637 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Controlador;
import Modelo.ModPartida;
import Modelo.Record;
import Modelo.Registrar;
import Vista.VRecord;
import Vista.VRegistrar;
import Vista.VistaMenu;
import Vista.VistaPart;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import bean.Music;
import java.io.File;
import javax.swing.WindowConstants;
/**
*
* @author USUARIO
*/
public class ContMenu{
private VistaMenu V;
public ContMenu(VistaMenu V) throws Exception {
this.V = V;
V.setVisible(true);
}
public void ActivarCampos(){
V.setNivel(true);
V.setIniP(true);
}
public void Salir(){
System.exit(0);
}
public void ComenzarPartida() throws SQLException, Exception{
ModPartida M = new ModPartida();
VistaPart VP = new VistaPart();
ContPartida C = new ContPartida(VP,M,this.V.getNivel().getSelectedIndex());
VP.setControlador(C);
}
public void RegistrarFrase(){
Registrar F = new Registrar();
VRegistrar VR = new VRegistrar();
ContRegistrar CR = new ContRegistrar(F,VR);
VR.setControlador(CR);
}
public void MostrarRecords() throws SQLException {
VRecord VRd = new VRecord();
Record MRd = new Record();
ContRecord CRd = new ContRecord(MRd,VRd);
VRd.setVisible(true);
VRd.setControlador(CRd);
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Controlador/ContMenu.java | Java | asf20 | 1,605 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Controlador;
import Modelo.Record;
import Vista.VRecord;
import java.sql.SQLException;
/**
*
* @author USUARIO
*/
public class ContRecord {
private Record R;
private VRecord VR;
ContRecord(Record MRd, VRecord VRd) throws SQLException {
this.R = MRd;
this.VR = VRd;
}
public void MostrarRecord() throws SQLException{
this.R.MostrarRecordN1();
for(int a = 0; a < 5; a++){
this.VR.getNivel1().setValueAt(this.R.getNombre().elementAt(a), a, 0);
this.VR.getNivel1().setValueAt(this.R.getTiempo().elementAt(a), a, 1);
}
this.R.MostrarRecordN2();
for(int a = 0; a < 5; a++){
this.VR.getNivel2().setValueAt(this.R.getNombre().elementAt(a), a, 0);
this.VR.getNivel2().setValueAt(this.R.getTiempo().elementAt(a), a, 1);
}
this.R.MostrarRecordN3();
for(int a = 0; a < 5; a++){
this.VR.getNivel3().setValueAt(this.R.getNombre().elementAt(a), a, 0);
this.VR.getNivel3().setValueAt(this.R.getTiempo().elementAt(a), a, 1);
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Controlador/ContRecord.java | Java | asf20 | 1,292 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Controlador;
import Modelo.Registrar;
import Modelo.RegistrarDAO;
import Vista.VRegistrar;
import javax.swing.JOptionPane;
/**
*
* @author Robert Alvarado
*/
public class ContRegistrar {
private Registrar F;
private VRegistrar VR;
private int Numero_Palabras;
ContRegistrar(Registrar F, VRegistrar VR) {
this.F = F;
this.VR = VR;
this.VR.setVisible(true);
}
public void Contar(String F){
this.Numero_Palabras = this.F.Contar(F);
if(this.Numero_Palabras == 1){
RegistrarDAO RD = new RegistrarDAO("Palabra_1",this.VR.getFrase().getText());
JOptionPane.showMessageDialog(null, "Palabra registrada Exitosamente");
this.VR.getFrase().setText("");
}else if(this.Numero_Palabras >= 2 && this.Numero_Palabras <= 5){
RegistrarDAO RD = new RegistrarDAO("Palabra_2",this.VR.getFrase().getText());
JOptionPane.showMessageDialog(null, "Frase registrada Exitosamente");
this.VR.getFrase().setText("");
}else if(this.Numero_Palabras >= 6 && this.Numero_Palabras <= 10){
RegistrarDAO RD = new RegistrarDAO("Palabra_3",this.VR.getFrase().getText());
JOptionPane.showMessageDialog(null, "Frase registrada Exitosamente");
this.VR.getFrase().setText("");
}else{
JOptionPane.showMessageDialog(null, "Frase muy grande, no debe exceder de 10 palabras");
this.VR.getFrase().setText("");
}
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Controlador/ContRegistrar.java | Java | asf20 | 1,652 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* El juego se ha realizado en netbeans 7.0.1
Alvarado Robert C.I. 18.052.474
Mendez Maryelis C.I. 19.887.067
Pernalete Alfa C.I. 19.164.564
Rivero Mayilde C.I. 18.430.469
*/
package pkg4.pkg1.primer.proyecto;
import Controlador.ContMenu;
import Vista.VistaMenu;
/**
*
* @author USUARIO
*/
public class PrimerProyecto {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
// TODO code application logic here
VistaMenu V = new VistaMenu();
ContMenu C = new ContMenu(V);
V.setControlador(C);
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/pkg4/pkg1/primer/proyecto/PrimerProyecto.java | Java | asf20 | 765 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* VistaMenu.java
*
* Created on 18-oct-2011, 19:50:35
*/
package Vista;
import Controlador.ContMenu;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
/**
*
* @author USUARIO
*/
public class VistaMenu extends javax.swing.JFrame {
private ContMenu C;
/** Creates new form VistaMenu */
public VistaMenu() {
initComponents();
this.Nivel.setSelectedIndex(0);
Pixelado.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/ahorcado1.JPG")));
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
Pixelado = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
Iniciar = new javax.swing.JButton();
Registrar = new javax.swing.JButton();
Records = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
Nivel = new javax.swing.JComboBox();
IniP = new javax.swing.JButton();
Salir = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(204, 204, 204));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setForeground(new java.awt.Color(255, 255, 255));
jPanel3.setBackground(new java.awt.Color(204, 255, 204));
jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.lightGray, java.awt.Color.lightGray));
jLabel3.setFont(new java.awt.Font("Gill Sans Ultra Bold", 1, 45));
jLabel3.setForeground(new java.awt.Color(51, 102, 255));
jLabel3.setText("¿..AHORCADO..?");
Pixelado.setIcon(new javax.swing.ImageIcon("C:\\Documents and Settings\\Robert Alvarado\\Escritorio\\FINAL_COLOR\\1-1-primer-proyecto\\src\\Imagenes\\ahorcado1.JPG")); // NOI18N
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
.addContainerGap())
.addComponent(Pixelado, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(Pixelado, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2.setBackground(new java.awt.Color(255, 255, 153));
Iniciar.setFont(new java.awt.Font("Agency FB", 1, 14));
Iniciar.setText("Jugar");
Iniciar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
IniciarActionPerformed(evt);
}
});
Registrar.setFont(new java.awt.Font("Agency FB", 1, 14));
Registrar.setText("Registrar Palabra");
Registrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RegistrarActionPerformed(evt);
}
});
Records.setFont(new java.awt.Font("Agency FB", 1, 14));
Records.setText("Records");
Records.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RecordsActionPerformed(evt);
}
});
jPanel1.setBackground(new java.awt.Color(235, 242, 249));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "<<Datos del Juego>>", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Agency FB", 1, 18), new java.awt.Color(0, 0, 0))); // NOI18N
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel2.setFont(new java.awt.Font("Tw Cen MT", 0, 14));
jLabel2.setText("Nivel del Juego:");
jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 30, 100, -1));
Nivel.setFont(new java.awt.Font("Tw Cen MT", 0, 12));
Nivel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nivel Basico", "Nivel Intermedio", "Nivel Avanzado" }));
Nivel.setEnabled(false);
Nivel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NivelActionPerformed(evt);
}
});
jPanel1.add(Nivel, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 30, 130, 20));
IniP.setFont(new java.awt.Font("Agency FB", 1, 14));
IniP.setText("Iniciar Partida");
IniP.setEnabled(false);
IniP.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
IniPActionPerformed(evt);
}
});
jPanel1.add(IniP, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 60, 130, 20));
Salir.setFont(new java.awt.Font("Agency FB", 1, 14));
Salir.setText("Salir");
Salir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SalirActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Iniciar, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Registrar, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
.addComponent(Records, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(Salir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(7, 7, 7)
.addComponent(Iniciar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Registrar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Records))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(13, 13, 13)
.addComponent(Salir)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 454, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void IniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IniciarActionPerformed
// TODO add your handling code here:
C.ActivarCampos();
}//GEN-LAST:event_IniciarActionPerformed
private void SalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SalirActionPerformed
// TODO add your handling code here:
C.Salir();
}//GEN-LAST:event_SalirActionPerformed
private void IniPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IniPActionPerformed
try {
C.ComenzarPartida();
} catch (Exception ex) {
Logger.getLogger(VistaMenu.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_IniPActionPerformed
private void NivelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NivelActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_NivelActionPerformed
private void RegistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RegistrarActionPerformed
// TODO add your handling code here:
this.C.RegistrarFrase();
}//GEN-LAST:event_RegistrarActionPerformed
private void RecordsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RecordsActionPerformed
try {
this.C.MostrarRecords();
} catch (SQLException ex) {
Logger.getLogger(VistaMenu.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_RecordsActionPerformed
public void setControlador(ContMenu C){
this.C = C;
}
public void setIniP(boolean a) {
this.IniP = IniP;
this.IniP.setEnabled(a);
}
public void setNivel(boolean a) {
this.Nivel = Nivel;
this.Nivel.setEnabled(a);
}
public JButton getSalir() {
return Salir;
}
public JComboBox getNivel() {
return Nivel;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(VistaMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(VistaMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(VistaMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(VistaMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new VistaMenu().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton IniP;
private javax.swing.JButton Iniciar;
private javax.swing.JComboBox Nivel;
private javax.swing.JLabel Pixelado;
private javax.swing.JButton Records;
private javax.swing.JButton Registrar;
private javax.swing.JButton Salir;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
// End of variables declaration//GEN-END:variables
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Vista/VistaMenu.java | Java | asf20 | 15,526 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* VRegistrar.java
*
* Created on 23/10/2011, 12:05:48 AM
*/
package Vista;
import Controlador.ContRegistrar;
import javax.swing.JTextField;
/**
*
* @author Robert Alvarado
*/
public class VRegistrar extends javax.swing.JFrame {
private ContRegistrar R;
/** Creates new form VRegistrar */
public VRegistrar() {
initComponents();
}
public void setControlador(ContRegistrar R){
this.R = R;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
Frase = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
Frase.setFont(new java.awt.Font("Tw Cen MT", 0, 14)); // NOI18N
getContentPane().add(Frase, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 591, 20));
jButton1.setFont(new java.awt.Font("Agency FB", 1, 14)); // NOI18N
jButton1.setText("Aceptar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 70, -1, -1));
jButton2.setFont(new java.awt.Font("Agency FB", 1, 14)); // NOI18N
jButton2.setText("Salir");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 70, 68, -1));
jLabel1.setFont(new java.awt.Font("Tw Cen MT", 1, 14)); // NOI18N
jLabel1.setText("Por favor Introduzca La(s) Palabra(s) que desea Registrar:");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 20, 350, -1));
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
this.R.Contar(this.Frase.getText());
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
dispose();
}//GEN-LAST:event_jButton2ActionPerformed
public JTextField getFrase() {
return Frase;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(VRegistrar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(VRegistrar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(VRegistrar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(VRegistrar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new VRegistrar().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField Frase;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Vista/VRegistrar.java | Java | asf20 | 5,186 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* VRecord.java
*
* Created on 23-oct-2011, 19:45:45
*/
package Vista;
import Controlador.ContRecord;
import java.sql.SQLException;
import javax.swing.JTable;
/**
*
* @author USUARIO
*/
public class VRecord extends javax.swing.JFrame {
private ContRecord C;
/** Creates new form VRecord */
public VRecord() {
initComponents();
}
public void setControlador(ContRecord C) throws SQLException{
this.C = C;
this.C.MostrarRecord();
}
public JTable getNivel1() {
return Nivel1;
}
public JTable getNivel2() {
return Nivel2;
}
public JTable getNivel3() {
return Nivel3;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jScrollPane4 = new javax.swing.JScrollPane();
Nivel1 = new javax.swing.JTable();
jPanel3 = new javax.swing.JPanel();
jScrollPane5 = new javax.swing.JScrollPane();
Nivel2 = new javax.swing.JTable();
jPanel1 = new javax.swing.JPanel();
jScrollPane3 = new javax.swing.JScrollPane();
Nivel3 = new javax.swing.JTable();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jButton1.setFont(new java.awt.Font("Agency FB", 1, 14));
jButton1.setText("SALIR");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 590, 150, -1));
jPanel2.setBackground(new java.awt.Color(255, 255, 153));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "<<Nivel Basico>>", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Agency FB", 1, 24), new java.awt.Color(0, 0, 0))); // NOI18N
Nivel1.setFont(new java.awt.Font("Tw Cen MT", 0, 14));
Nivel1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null},
{null, null},
{null, null},
{null, null}
},
new String [] {
"Nombre", "Tiempo"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jScrollPane4.setViewportView(Nivel1);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 450, 190));
jPanel3.setBackground(new java.awt.Color(204, 255, 204));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "<<Nivel Intermedio>>", javax.swing.border.TitledBorder.RIGHT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Agency FB", 1, 24), new java.awt.Color(0, 0, 0))); // NOI18N
Nivel2.setFont(new java.awt.Font("Tw Cen MT", 0, 14));
Nivel2.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null},
{null, null},
{null, null},
{null, null}
},
new String [] {
"Nombre", "Tiempo"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jScrollPane5.setViewportView(Nivel2);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
.addContainerGap())
);
getContentPane().add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 190, 450, -1));
jPanel1.setBackground(new java.awt.Color(255, 255, 153));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "<<Nivel Avanzado>>", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Agency FB", 1, 24), new java.awt.Color(0, 0, 0))); // NOI18N
Nivel3.setFont(new java.awt.Font("Tw Cen MT", 0, 14));
Nivel3.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null},
{null, null},
{null, null},
{null, null}
},
new String [] {
"Nombre", "Tiempo"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jScrollPane3.setViewportView(Nivel3);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
.addContainerGap())
);
getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 380, 450, -1));
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
dispose();
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(VRecord.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(VRecord.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(VRecord.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(VRecord.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new VRecord().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTable Nivel1;
private javax.swing.JTable Nivel2;
private javax.swing.JTable Nivel3;
private javax.swing.JButton jButton1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
// End of variables declaration//GEN-END:variables
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Vista/VRecord.java | Java | asf20 | 10,920 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* VistaPart.java
*
* Created on 18-oct-2011, 20:48:54
*/
package Vista;
import Controlador.ContPartida;
import bean.Music;
import java.awt.Color;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
*
* @author USUARIO
*/
public class VistaPart extends javax.swing.JFrame {
private ContPartida C;
/** Creates new form VistaPart */
public VistaPart() {
initComponents();
}
public void setControlador(ContPartida C){
this.C = C;
}
public void setAhorcado(String Ruta) {
ImagenLabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource(Ruta)));
}
public void setjLabel1(boolean a) {
this.jLabel1.setEnabled(a);
}
public void setjLabel10(boolean a) {
this.jLabel10.setEnabled(a);
}
public void setjLabel11(boolean a) {
this.jLabel11.setEnabled(a);
}
public void setjLabel12(boolean a) {
this.jLabel12.setEnabled(a);
}
public void setjLabel13(boolean a) {
this.jLabel13.setEnabled(a);
}
public void setjLabel14(boolean a) {
this.jLabel14.setEnabled(a);
}
public void setjLabel15(boolean a) {
this.jLabel15.setEnabled(a);
}
public void setjLabel16(boolean a) {
this.jLabel16.setEnabled(a);
}
public void setjLabel17(boolean a) {
this.jLabel17.setEnabled(a);
}
public void setjLabel18(boolean a) {
this.jLabel18.setEnabled(a);
}
public void setjLabel2(boolean a) {
this.jLabel2.setEnabled(a);
}
public void setjLabel3(boolean a) {
this.jLabel3.setEnabled(a);
}
public void setjLabel4(boolean a) {
this.jLabel4.setEnabled(a);
}
public void setjLabel5(boolean a) {
this.jLabel5.setEnabled(a);
}
public void setjLabel6(boolean a) {
this.jLabel6.setEnabled(a);
}
public void setjLabel7(boolean a) {
this.jLabel7.setEnabled(a);
}
public void setjLabel8(boolean a) {
this.jLabel8.setEnabled(a);
}
public void setjLabel9(boolean a) {
this.jLabel9.setEnabled(a);
}
public JLabel getjLabel1() {
return jLabel1;
}
public JLabel getjLabel10() {
return jLabel10;
}
public JLabel getjLabel11() {
return jLabel11;
}
public JLabel getjLabel12() {
return jLabel12;
}
public JLabel getjLabel13() {
return jLabel13;
}
public JLabel getjLabel14() {
return jLabel14;
}
public JLabel getjLabel15() {
return jLabel15;
}
public JLabel getjLabel16() {
return jLabel16;
}
public JLabel getjLabel17() {
return jLabel17;
}
public JLabel getjLabel18() {
return jLabel18;
}
public JLabel getjLabel2() {
return jLabel2;
}
public JLabel getjLabel3() {
return jLabel3;
}
public JLabel getjLabel4() {
return jLabel4;
}
public JLabel getjLabel5() {
return jLabel5;
}
public JLabel getjLabel6() {
return jLabel6;
}
public JLabel getjLabel7() {
return jLabel7;
}
public JLabel getjLabel8() {
return jLabel8;
}
public JLabel getjLabel9() {
return jLabel9;
}
public JLabel getjLabel100() {
return jLabel100;
}
public JLabel getjLabel101() {
return jLabel101;
}
public JLabel getjLabel102() {
return jLabel102;
}
public JLabel getjLabel103() {
return jLabel103;
}
public JLabel getjLabel104() {
return jLabel104;
}
public JLabel getjLabel105() {
return jLabel105;
}
public JLabel getjLabel106() {
return jLabel106;
}
public JLabel getjLabel107() {
return jLabel107;
}
public JLabel getjLabel108() {
return jLabel108;
}
public JLabel getjLabel109() {
return jLabel109;
}
public JLabel getjLabel110() {
return jLabel110;
}
public JLabel getjLabel111() {
return jLabel111;
}
public JLabel getjLabel112() {
return jLabel112;
}
public JLabel getjLabel113() {
return jLabel113;
}
public JLabel getjLabel114() {
return jLabel114;
}
public JLabel getjLabel115() {
return jLabel115;
}
public JLabel getjLabel116() {
return jLabel116;
}
public JLabel getjLabel117() {
return jLabel117;
}
public JLabel getjLabel118() {
return jLabel118;
}
public JLabel getjLabel119() {
return jLabel119;
}
public JLabel getjLabel120() {
return jLabel120;
}
public JLabel getjLabel121() {
return jLabel121;
}
public JLabel getjLabel122() {
return jLabel122;
}
public JLabel getjLabel123() {
return jLabel123;
}
public JLabel getjLabel19() {
return jLabel19;
}
public JLabel getjLabel20() {
return jLabel20;
}
public JLabel getjLabel21() {
return jLabel21;
}
public JLabel getjLabel22() {
return jLabel22;
}
public JLabel getjLabel23() {
return jLabel23;
}
public JLabel getjLabel24() {
return jLabel24;
}
public JLabel getjLabel25() {
return jLabel25;
}
public JLabel getjLabel26() {
return jLabel26;
}
public JLabel getjLabel27() {
return jLabel27;
}
public JLabel getjLabel28() {
return jLabel28;
}
public JLabel getjLabel29() {
return jLabel29;
}
public JLabel getjLabel30() {
return jLabel30;
}
public JLabel getjLabel31() {
return jLabel31;
}
public JLabel getjLabel32() {
return jLabel32;
}
public JLabel getjLabel33() {
return jLabel33;
}
public JLabel getjLabel34() {
return jLabel34;
}
public JLabel getjLabel35() {
return jLabel35;
}
public JLabel getjLabel36() {
return jLabel36;
}
public JLabel getjLabel37() {
return jLabel37;
}
public JLabel getjLabel38() {
return jLabel38;
}
public JLabel getjLabel39() {
return jLabel39;
}
public JLabel getjLabel40() {
return jLabel40;
}
public JLabel getjLabel41() {
return jLabel41;
}
public JLabel getjLabel42() {
return jLabel42;
}
public JLabel getjLabel43() {
return jLabel43;
}
public JLabel getjLabel44() {
return jLabel44;
}
public JLabel getjLabel45() {
return jLabel45;
}
public JLabel getjLabel46() {
return jLabel46;
}
public JLabel getjLabel47() {
return jLabel47;
}
public JLabel getjLabel48() {
return jLabel48;
}
public JLabel getjLabel49() {
return jLabel49;
}
public JLabel getjLabel50() {
return jLabel50;
}
public JLabel getjLabel51() {
return jLabel51;
}
public JLabel getjLabel52() {
return jLabel52;
}
public JLabel getjLabel53() {
return jLabel53;
}
public JLabel getjLabel54() {
return jLabel54;
}
public JLabel getjLabel55() {
return jLabel55;
}
public JLabel getjLabel56() {
return jLabel56;
}
public JLabel getjLabel57() {
return jLabel57;
}
public JLabel getjLabel58() {
return jLabel58;
}
public JLabel getjLabel59() {
return jLabel59;
}
public JLabel getjLabel60() {
return jLabel60;
}
public JLabel getjLabel61() {
return jLabel61;
}
public JLabel getjLabel62() {
return jLabel62;
}
public JLabel getjLabel63() {
return jLabel63;
}
public JLabel getjLabel64() {
return jLabel64;
}
public JLabel getjLabel65() {
return jLabel65;
}
public JLabel getjLabel66() {
return jLabel66;
}
public JLabel getjLabel67() {
return jLabel67;
}
public JLabel getjLabel68() {
return jLabel68;
}
public JLabel getjLabel69() {
return jLabel69;
}
public JLabel getjLabel70() {
return jLabel70;
}
public JLabel getjLabel71() {
return jLabel71;
}
public JLabel getjLabel72() {
return jLabel72;
}
public JLabel getjLabel73() {
return jLabel73;
}
public JLabel getjLabel74() {
return jLabel74;
}
public JLabel getjLabel75() {
return jLabel75;
}
public JLabel getjLabel76() {
return jLabel76;
}
public JLabel getjLabel77() {
return jLabel77;
}
public JLabel getjLabel78() {
return jLabel78;
}
public JLabel getjLabel79() {
return jLabel79;
}
public JLabel getjLabel80() {
return jLabel80;
}
public JLabel getjLabel81() {
return jLabel81;
}
public JLabel getjLabel82() {
return jLabel82;
}
public JLabel getjLabel83() {
return jLabel83;
}
public JLabel getjLabel84() {
return jLabel84;
}
public JLabel getjLabel85() {
return jLabel85;
}
public JLabel getjLabel86() {
return jLabel86;
}
public JLabel getjLabel87() {
return jLabel87;
}
public JLabel getjLabel88() {
return jLabel88;
}
public JLabel getjLabel89() {
return jLabel89;
}
public JLabel getjLabel90() {
return jLabel90;
}
public JLabel getjLabel91() {
return jLabel91;
}
public JLabel getjLabel92() {
return jLabel92;
}
public JLabel getjLabel93() {
return jLabel93;
}
public JLabel getjLabel94() {
return jLabel94;
}
public JLabel getjLabel95() {
return jLabel95;
}
public JLabel getjLabel96() {
return jLabel96;
}
public JLabel getjLabel97() {
return jLabel97;
}
public JLabel getjLabel98() {
return jLabel98;
}
public JLabel getjLabel99() {
return jLabel99;
}
public void setjButton1(boolean a) {
this.jButton1.setEnabled(a);
}
public void setjButton10(boolean a) {
this.jButton10.setEnabled(a);
}
public void setjButton11(boolean a) {
this.jButton11.setEnabled(a);
}
public void setjButton12(boolean a) {
this.jButton12.setEnabled(a);
}
public void setjButton13(boolean a) {
this.jButton13.setEnabled(a);
}
public void setjButton14(boolean a) {
this.jButton14.setEnabled(a);
}
public void setjButton15(boolean a) {
this.jButton15.setEnabled(a);
}
public void setjButton16(boolean a) {
this.jButton16.setEnabled(a);
}
public void setjButton17(boolean a) {
this.jButton17.setEnabled(a);
}
public void setjButton18(boolean a) {
this.jButton18.setEnabled(a);
}
public void setjButton19(boolean a) {
this.jButton19.setEnabled(a);
}
public void setjButton2(boolean a) {
this.jButton2.setEnabled(a);
}
public void setjButton20(boolean a) {
this.jButton20.setEnabled(a);
}
public void setjButton21(boolean a) {
this.jButton21.setEnabled(a);
}
public void setjButton22(boolean a) {
this.jButton22.setEnabled(a);
}
public void setjButton23(boolean a) {
this.jButton23.setEnabled(a);
}
public void setjButton24(boolean a) {
this.jButton24.setEnabled(a);
}
public void setjButton25(boolean a) {
this.jButton25.setEnabled(a);
}
public void setjButton26(boolean a) {
this.jButton26.setEnabled(a);
}
public void setjButton27(boolean a) {
this.jButton27.setEnabled(a);
}
public void setjButton3(boolean a) {
this.jButton3.setEnabled(a);
}
public void setjButton4(boolean a) {
this.jButton4.setEnabled(a);
}
public void setjButton5(boolean a) {
this.jButton5.setEnabled(a);
}
public void setjButton6(boolean a) {
this.jButton6.setEnabled(a);
}
public void setjButton7(boolean a) {
this.jButton7.setEnabled(a);
}
public void setjButton8(boolean a) {
this.jButton8.setEnabled(a);
}
public void setjButton9(boolean a) {
this.jButton9.setEnabled(a);
}
public void setMensaje(String Men, boolean a, Color b) {
this.Mensaje.setText(Men);
this.Mensaje.setVisible(a);
this.Mensaje.setForeground(b);
}
public void HablitarRegistro(boolean a){
this.Aceptar.setVisible(a);
this.Nombre.setVisible(a);
this.JNombre.setVisible(a);
}
public JLabel getReloj() {
return Reloj;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel2 = new javax.swing.JPanel();
Reiniciar = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jButton10 = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
jButton12 = new javax.swing.JButton();
jButton13 = new javax.swing.JButton();
jButton14 = new javax.swing.JButton();
jButton15 = new javax.swing.JButton();
jButton16 = new javax.swing.JButton();
jButton17 = new javax.swing.JButton();
jButton18 = new javax.swing.JButton();
jButton19 = new javax.swing.JButton();
jButton20 = new javax.swing.JButton();
jButton21 = new javax.swing.JButton();
jButton22 = new javax.swing.JButton();
jButton23 = new javax.swing.JButton();
jButton24 = new javax.swing.JButton();
jButton25 = new javax.swing.JButton();
jButton26 = new javax.swing.JButton();
jButton27 = new javax.swing.JButton();
jButton28 = new javax.swing.JButton();
Ahorcado = new javax.swing.JPanel();
ImagenLabel = new javax.swing.JLabel();
Mensaje = new javax.swing.JLabel();
Nombre = new javax.swing.JLabel();
JNombre = new javax.swing.JTextField();
Aceptar = new javax.swing.JButton();
Reloj = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
jLabel22 = new javax.swing.JLabel();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
jLabel25 = new javax.swing.JLabel();
jLabel26 = new javax.swing.JLabel();
jLabel27 = new javax.swing.JLabel();
jLabel28 = new javax.swing.JLabel();
jLabel29 = new javax.swing.JLabel();
jLabel30 = new javax.swing.JLabel();
jLabel31 = new javax.swing.JLabel();
jLabel32 = new javax.swing.JLabel();
jLabel33 = new javax.swing.JLabel();
jLabel34 = new javax.swing.JLabel();
jLabel35 = new javax.swing.JLabel();
jLabel36 = new javax.swing.JLabel();
jLabel37 = new javax.swing.JLabel();
jLabel38 = new javax.swing.JLabel();
jLabel39 = new javax.swing.JLabel();
jLabel40 = new javax.swing.JLabel();
jLabel41 = new javax.swing.JLabel();
jLabel42 = new javax.swing.JLabel();
jLabel43 = new javax.swing.JLabel();
jLabel44 = new javax.swing.JLabel();
jLabel45 = new javax.swing.JLabel();
jLabel46 = new javax.swing.JLabel();
jLabel47 = new javax.swing.JLabel();
jLabel48 = new javax.swing.JLabel();
jLabel49 = new javax.swing.JLabel();
jLabel50 = new javax.swing.JLabel();
jLabel51 = new javax.swing.JLabel();
jLabel52 = new javax.swing.JLabel();
jLabel53 = new javax.swing.JLabel();
jLabel54 = new javax.swing.JLabel();
jLabel55 = new javax.swing.JLabel();
jLabel56 = new javax.swing.JLabel();
jLabel57 = new javax.swing.JLabel();
jLabel58 = new javax.swing.JLabel();
jLabel59 = new javax.swing.JLabel();
jLabel60 = new javax.swing.JLabel();
jLabel61 = new javax.swing.JLabel();
jLabel62 = new javax.swing.JLabel();
jLabel63 = new javax.swing.JLabel();
jLabel64 = new javax.swing.JLabel();
jLabel65 = new javax.swing.JLabel();
jLabel66 = new javax.swing.JLabel();
jLabel67 = new javax.swing.JLabel();
jLabel68 = new javax.swing.JLabel();
jLabel69 = new javax.swing.JLabel();
jLabel70 = new javax.swing.JLabel();
jLabel71 = new javax.swing.JLabel();
jLabel72 = new javax.swing.JLabel();
jLabel73 = new javax.swing.JLabel();
jLabel74 = new javax.swing.JLabel();
jLabel75 = new javax.swing.JLabel();
jLabel76 = new javax.swing.JLabel();
jLabel77 = new javax.swing.JLabel();
jLabel78 = new javax.swing.JLabel();
jLabel79 = new javax.swing.JLabel();
jLabel80 = new javax.swing.JLabel();
jLabel81 = new javax.swing.JLabel();
jLabel82 = new javax.swing.JLabel();
jLabel83 = new javax.swing.JLabel();
jLabel84 = new javax.swing.JLabel();
jLabel85 = new javax.swing.JLabel();
jLabel86 = new javax.swing.JLabel();
jLabel87 = new javax.swing.JLabel();
jLabel88 = new javax.swing.JLabel();
jLabel89 = new javax.swing.JLabel();
jLabel90 = new javax.swing.JLabel();
jLabel91 = new javax.swing.JLabel();
jLabel92 = new javax.swing.JLabel();
jLabel93 = new javax.swing.JLabel();
jLabel94 = new javax.swing.JLabel();
jLabel95 = new javax.swing.JLabel();
jLabel96 = new javax.swing.JLabel();
jLabel97 = new javax.swing.JLabel();
jLabel98 = new javax.swing.JLabel();
jLabel99 = new javax.swing.JLabel();
jLabel100 = new javax.swing.JLabel();
jLabel101 = new javax.swing.JLabel();
jLabel102 = new javax.swing.JLabel();
jLabel103 = new javax.swing.JLabel();
jLabel104 = new javax.swing.JLabel();
jLabel105 = new javax.swing.JLabel();
jLabel106 = new javax.swing.JLabel();
jLabel107 = new javax.swing.JLabel();
jLabel108 = new javax.swing.JLabel();
jLabel109 = new javax.swing.JLabel();
jLabel110 = new javax.swing.JLabel();
jLabel111 = new javax.swing.JLabel();
jLabel112 = new javax.swing.JLabel();
jLabel113 = new javax.swing.JLabel();
jLabel114 = new javax.swing.JLabel();
jLabel115 = new javax.swing.JLabel();
jLabel116 = new javax.swing.JLabel();
jLabel117 = new javax.swing.JLabel();
jLabel118 = new javax.swing.JLabel();
jLabel119 = new javax.swing.JLabel();
jLabel120 = new javax.swing.JLabel();
jLabel121 = new javax.swing.JLabel();
jLabel122 = new javax.swing.JLabel();
jLabel123 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(255, 255, 255));
jPanel2.setBackground(new java.awt.Color(204, 255, 51));
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.lightGray, java.awt.Color.lightGray));
jPanel2.setForeground(new java.awt.Color(255, 255, 255));
Reiniciar.setFont(new java.awt.Font("Agency FB", 1, 13));
Reiniciar.setText("Reiniciar");
Reiniciar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ReiniciarActionPerformed(evt);
}
});
jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204), 2));
jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jButton1.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton1.setForeground(new java.awt.Color(1, 1, 1));
jButton1.setText("A");
jButton1.setMaximumSize(new java.awt.Dimension(43, 23));
jButton1.setMinimumSize(new java.awt.Dimension(43, 23));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel3.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 50, 50, 40));
jButton2.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton2.setText("B");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jPanel3.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 90, 50, 40));
jButton3.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton3.setText("K");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jPanel3.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 50, 50, 40));
jButton4.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton4.setText("C");
jButton4.setMaximumSize(new java.awt.Dimension(43, 23));
jButton4.setMinimumSize(new java.awt.Dimension(43, 23));
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jPanel3.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 90, 50, 40));
jButton5.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton5.setText("L");
jButton5.setMaximumSize(new java.awt.Dimension(43, 23));
jButton5.setMinimumSize(new java.awt.Dimension(43, 23));
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jPanel3.add(jButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 50, 50, 40));
jButton6.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton6.setText("J");
jButton6.setMaximumSize(new java.awt.Dimension(43, 23));
jButton6.setMinimumSize(new java.awt.Dimension(43, 23));
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jPanel3.add(jButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 50, 50, 40));
jButton7.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton7.setText("D");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jPanel3.add(jButton7, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 50, 50, 40));
jButton8.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton8.setText("E");
jButton8.setMaximumSize(new java.awt.Dimension(43, 23));
jButton8.setMinimumSize(new java.awt.Dimension(43, 23));
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jPanel3.add(jButton8, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 10, 50, 40));
jButton9.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton9.setText("F");
jButton9.setMaximumSize(new java.awt.Dimension(43, 23));
jButton9.setMinimumSize(new java.awt.Dimension(43, 23));
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
jPanel3.add(jButton9, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 50, 50, 40));
jButton10.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton10.setText("G");
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
jPanel3.add(jButton10, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 50, 50, 40));
jButton11.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton11.setText("M");
jButton11.setMaximumSize(new java.awt.Dimension(43, 23));
jButton11.setMinimumSize(new java.awt.Dimension(43, 23));
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
jPanel3.add(jButton11, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 90, 50, 40));
jButton12.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton12.setText("H");
jButton12.setMaximumSize(new java.awt.Dimension(43, 23));
jButton12.setMinimumSize(new java.awt.Dimension(43, 23));
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
jPanel3.add(jButton12, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 50, 50, 40));
jButton13.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton13.setText("N");
jButton13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton13ActionPerformed(evt);
}
});
jPanel3.add(jButton13, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 90, 50, 40));
jButton14.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton14.setText("Ñ");
jButton14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton14ActionPerformed(evt);
}
});
jPanel3.add(jButton14, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 90, 50, 40));
jButton15.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton15.setText("O");
jButton15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton15ActionPerformed(evt);
}
});
jPanel3.add(jButton15, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 10, 50, 40));
jButton16.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton16.setText("P");
jButton16.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton16ActionPerformed(evt);
}
});
jPanel3.add(jButton16, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 10, 50, 40));
jButton17.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton17.setText("R");
jButton17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton17ActionPerformed(evt);
}
});
jPanel3.add(jButton17, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 10, 50, 40));
jButton18.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton18.setText("S");
jButton18.setMaximumSize(new java.awt.Dimension(43, 23));
jButton18.setMinimumSize(new java.awt.Dimension(43, 23));
jButton18.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton18ActionPerformed(evt);
}
});
jPanel3.add(jButton18, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 50, 50, 40));
jButton19.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton19.setText("T");
jButton19.setMaximumSize(new java.awt.Dimension(43, 23));
jButton19.setMinimumSize(new java.awt.Dimension(43, 23));
jButton19.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton19ActionPerformed(evt);
}
});
jPanel3.add(jButton19, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 10, 50, 40));
jButton20.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton20.setText("U");
jButton20.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton20ActionPerformed(evt);
}
});
jPanel3.add(jButton20, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 10, 50, 40));
jButton21.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton21.setText("V");
jButton21.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton21ActionPerformed(evt);
}
});
jPanel3.add(jButton21, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 90, 50, 40));
jButton22.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton22.setText("W");
jButton22.setPreferredSize(new java.awt.Dimension(43, 43));
jButton22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton22ActionPerformed(evt);
}
});
jPanel3.add(jButton22, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 10, 50, 40));
jButton23.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton23.setText("X");
jButton23.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton23ActionPerformed(evt);
}
});
jPanel3.add(jButton23, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 90, 50, 40));
jButton24.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton24.setText("Y");
jButton24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton24ActionPerformed(evt);
}
});
jPanel3.add(jButton24, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 10, 50, 40));
jButton25.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton25.setText("Z");
jButton25.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton25ActionPerformed(evt);
}
});
jPanel3.add(jButton25, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 90, 50, 40));
jButton26.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton26.setText("Q");
jButton26.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton26ActionPerformed(evt);
}
});
jPanel3.add(jButton26, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 50, 40));
jButton27.setFont(new java.awt.Font("Gill Sans Ultra Bold", 0, 12));
jButton27.setText("I");
jButton27.setMaximumSize(new java.awt.Dimension(43, 23));
jButton27.setMinimumSize(new java.awt.Dimension(43, 23));
jButton27.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton27ActionPerformed(evt);
}
});
jPanel3.add(jButton27, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 10, 50, 40));
jButton28.setFont(new java.awt.Font("Agency FB", 1, 13));
jButton28.setText("Salir");
jButton28.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton28ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(Reiniciar, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 519, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton28, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton28, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(Reiniciar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(27, Short.MAX_VALUE))
);
Ahorcado.setBackground(new java.awt.Color(255, 255, 255));
Ahorcado.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));
ImagenLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Aho0.gif"))); // NOI18N
ImagenLabel.setMaximumSize(new java.awt.Dimension(100, 100));
ImagenLabel.setMinimumSize(new java.awt.Dimension(100, 100));
Mensaje.setFont(new java.awt.Font("Agency FB", 1, 70));
Nombre.setFont(new java.awt.Font("Tw Cen MT", 0, 14));
Nombre.setText("Ingrese su Nombre:");
JNombre.setFont(new java.awt.Font("Tw Cen MT", 0, 14));
Aceptar.setFont(new java.awt.Font("Agency FB", 1, 14));
Aceptar.setText("Aceptar");
Aceptar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
AceptarActionPerformed(evt);
}
});
Reloj.setFont(new java.awt.Font("Gill Sans Ultra Bold", 1, 28));
Reloj.setText("00:00:00");
javax.swing.GroupLayout AhorcadoLayout = new javax.swing.GroupLayout(Ahorcado);
Ahorcado.setLayout(AhorcadoLayout);
AhorcadoLayout.setHorizontalGroup(
AhorcadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(AhorcadoLayout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(ImagenLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(AhorcadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(AhorcadoLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Reloj, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(AhorcadoLayout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(Mensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
.addGroup(AhorcadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(AhorcadoLayout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(JNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, AhorcadoLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Aceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)))))
.addContainerGap())
);
AhorcadoLayout.setVerticalGroup(
AhorcadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(AhorcadoLayout.createSequentialGroup()
.addContainerGap()
.addGroup(AhorcadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ImagenLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
.addGroup(AhorcadoLayout.createSequentialGroup()
.addGap(15, 15, 15)
.addComponent(Reloj, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(AhorcadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(AhorcadoLayout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(JNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Aceptar))
.addComponent(Nombre)
.addComponent(Mensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(34, 34, 34)))
.addContainerGap())
);
jPanel4.setBackground(new java.awt.Color(255, 255, 102));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "<<Frase>>", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Agency FB", 1, 24), new java.awt.Color(0, 0, 0))); // NOI18N
jPanel1.setForeground(new java.awt.Color(241, 243, 248));
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel1.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel1.setText("_");
jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, -1, -1));
jLabel2.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel2.setText("_");
jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, -1, -1));
jLabel3.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel3.setText("_");
jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 40, -1, -1));
jLabel4.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel4.setText("_");
jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 40, -1, -1));
jLabel5.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel5.setText("_");
jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 40, -1, -1));
jLabel6.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel6.setText("_");
jPanel1.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 40, -1, -1));
jLabel7.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel7.setText("_");
jPanel1.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 40, -1, -1));
jLabel8.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel8.setText("_");
jPanel1.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 40, -1, -1));
jLabel9.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel9.setText("_");
jPanel1.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 40, -1, -1));
jLabel10.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel10.setText("_");
jPanel1.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 40, -1, -1));
jLabel11.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel11.setText("_");
jPanel1.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 40, -1, -1));
jLabel12.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel12.setText("_");
jPanel1.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 40, -1, -1));
jLabel13.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel13.setText("_");
jPanel1.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 40, -1, -1));
jLabel14.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel14.setText("_");
jPanel1.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 40, -1, -1));
jLabel15.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel15.setText("_");
jPanel1.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 40, -1, -1));
jLabel16.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel16.setText("_");
jPanel1.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 40, -1, -1));
jLabel17.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel17.setText("_");
jPanel1.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 40, -1, -1));
jLabel18.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel18.setText("_");
jPanel1.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 40, -1, -1));
jLabel19.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel19.setText("_");
jPanel1.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 40, -1, -1));
jLabel20.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel20.setText("_");
jPanel1.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 40, -1, -1));
jLabel21.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel21.setText("_");
jPanel1.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 40, -1, -1));
jLabel22.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel22.setText("_");
jPanel1.add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 40, -1, -1));
jLabel23.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel23.setText("_");
jPanel1.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 40, -1, -1));
jLabel24.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel24.setText("_");
jPanel1.add(jLabel24, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 40, -1, -1));
jLabel25.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel25.setText("_");
jPanel1.add(jLabel25, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 40, -1, -1));
jLabel26.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel26.setText("_");
jPanel1.add(jLabel26, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 40, -1, -1));
jLabel27.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel27.setText("_");
jPanel1.add(jLabel27, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 40, -1, -1));
jLabel28.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel28.setText("_");
jPanel1.add(jLabel28, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 40, -1, -1));
jLabel29.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel29.setText("_");
jPanel1.add(jLabel29, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 40, -1, -1));
jLabel30.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel30.setText("_");
jPanel1.add(jLabel30, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 40, -1, -1));
jLabel31.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel31.setText("_");
jPanel1.add(jLabel31, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 40, -1, -1));
jLabel32.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel32.setText("_");
jPanel1.add(jLabel32, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 40, -1, -1));
jLabel33.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel33.setText("_");
jPanel1.add(jLabel33, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 40, -1, -1));
jLabel34.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel34.setText("_");
jPanel1.add(jLabel34, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, -1, -1));
jLabel35.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel35.setText("_");
jPanel1.add(jLabel35, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 70, -1, -1));
jLabel36.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel36.setText("_");
jPanel1.add(jLabel36, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 70, -1, -1));
jLabel37.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel37.setText("_");
jPanel1.add(jLabel37, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 70, -1, -1));
jLabel38.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel38.setText("_");
jPanel1.add(jLabel38, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 70, -1, -1));
jLabel39.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel39.setText("_");
jPanel1.add(jLabel39, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 70, -1, -1));
jLabel40.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel40.setText("_");
jPanel1.add(jLabel40, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 70, -1, -1));
jLabel41.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel41.setText("_");
jPanel1.add(jLabel41, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 70, -1, -1));
jLabel42.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel42.setText("_");
jPanel1.add(jLabel42, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 70, -1, -1));
jLabel43.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel43.setText("_");
jPanel1.add(jLabel43, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 70, -1, -1));
jLabel44.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel44.setText("_");
jPanel1.add(jLabel44, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 70, -1, -1));
jLabel45.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel45.setText("_");
jPanel1.add(jLabel45, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 70, -1, -1));
jLabel46.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel46.setText("_");
jPanel1.add(jLabel46, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 70, -1, -1));
jLabel47.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel47.setText("_");
jPanel1.add(jLabel47, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 70, -1, -1));
jLabel48.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel48.setText("_");
jPanel1.add(jLabel48, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 70, -1, -1));
jLabel49.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel49.setText("_");
jPanel1.add(jLabel49, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 70, -1, -1));
jLabel50.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel50.setText("_");
jPanel1.add(jLabel50, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 70, -1, -1));
jLabel51.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel51.setText("_");
jPanel1.add(jLabel51, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 70, -1, -1));
jLabel52.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel52.setText("_");
jPanel1.add(jLabel52, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 70, -1, -1));
jLabel53.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel53.setText("_");
jPanel1.add(jLabel53, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 70, -1, -1));
jLabel54.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel54.setText("_");
jPanel1.add(jLabel54, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 70, -1, -1));
jLabel55.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel55.setText("_");
jPanel1.add(jLabel55, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 70, -1, -1));
jLabel56.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel56.setText("_");
jPanel1.add(jLabel56, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 70, -1, -1));
jLabel57.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel57.setText("_");
jPanel1.add(jLabel57, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 70, -1, -1));
jLabel58.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel58.setText("_");
jPanel1.add(jLabel58, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 70, -1, -1));
jLabel59.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel59.setText("_");
jPanel1.add(jLabel59, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 70, -1, -1));
jLabel60.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel60.setText("_");
jPanel1.add(jLabel60, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 70, -1, -1));
jLabel61.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel61.setText("_");
jPanel1.add(jLabel61, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 70, -1, -1));
jLabel62.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel62.setText("_");
jPanel1.add(jLabel62, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 70, -1, -1));
jLabel63.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel63.setText("_");
jPanel1.add(jLabel63, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 70, -1, -1));
jLabel64.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel64.setText("_");
jPanel1.add(jLabel64, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, -1, -1));
jLabel65.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel65.setText("_");
jPanel1.add(jLabel65, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 100, -1, -1));
jLabel66.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel66.setText("_");
jPanel1.add(jLabel66, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 100, -1, -1));
jLabel67.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel67.setText("_");
jPanel1.add(jLabel67, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 100, -1, -1));
jLabel68.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel68.setText("_");
jPanel1.add(jLabel68, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 100, -1, -1));
jLabel69.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel69.setText("_");
jPanel1.add(jLabel69, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 100, -1, -1));
jLabel70.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel70.setText("_");
jPanel1.add(jLabel70, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 100, -1, -1));
jLabel71.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel71.setText("_");
jPanel1.add(jLabel71, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 100, -1, -1));
jLabel72.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel72.setText("_");
jPanel1.add(jLabel72, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 100, -1, -1));
jLabel73.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel73.setText("_");
jPanel1.add(jLabel73, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 100, -1, -1));
jLabel74.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel74.setText("_");
jPanel1.add(jLabel74, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 100, -1, -1));
jLabel75.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel75.setText("_");
jPanel1.add(jLabel75, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 100, -1, -1));
jLabel76.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel76.setText("_");
jPanel1.add(jLabel76, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 100, -1, -1));
jLabel77.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel77.setText("_");
jPanel1.add(jLabel77, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 100, -1, -1));
jLabel78.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel78.setText("_");
jPanel1.add(jLabel78, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 100, -1, -1));
jLabel79.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel79.setText("_");
jPanel1.add(jLabel79, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 100, -1, -1));
jLabel80.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel80.setText("_");
jPanel1.add(jLabel80, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 100, -1, -1));
jLabel81.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel81.setText("_");
jPanel1.add(jLabel81, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 100, -1, -1));
jLabel82.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel82.setText("_");
jPanel1.add(jLabel82, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 100, -1, -1));
jLabel83.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel83.setText("_");
jPanel1.add(jLabel83, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 100, -1, -1));
jLabel84.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel84.setText("_");
jPanel1.add(jLabel84, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 100, -1, -1));
jLabel85.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel85.setText("_");
jPanel1.add(jLabel85, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 100, -1, -1));
jLabel86.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel86.setText("_");
jPanel1.add(jLabel86, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 100, -1, -1));
jLabel87.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel87.setText("_");
jPanel1.add(jLabel87, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 100, -1, -1));
jLabel88.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel88.setText("_");
jPanel1.add(jLabel88, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 100, -1, -1));
jLabel89.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel89.setText("_");
jPanel1.add(jLabel89, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 100, -1, -1));
jLabel90.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel90.setText("_");
jPanel1.add(jLabel90, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 100, -1, -1));
jLabel91.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel91.setText("_");
jPanel1.add(jLabel91, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 100, -1, -1));
jLabel92.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel92.setText("_");
jPanel1.add(jLabel92, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 100, -1, -1));
jLabel93.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel93.setText("_");
jPanel1.add(jLabel93, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 100, -1, -1));
jLabel94.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel94.setText("_");
jPanel1.add(jLabel94, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 130, -1, -1));
jLabel95.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel95.setText("_");
jPanel1.add(jLabel95, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 130, -1, -1));
jLabel96.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel96.setText("_");
jPanel1.add(jLabel96, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 130, -1, -1));
jLabel97.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel97.setText("_");
jPanel1.add(jLabel97, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 130, -1, -1));
jLabel98.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel98.setText("_");
jPanel1.add(jLabel98, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 130, -1, -1));
jLabel99.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel99.setText("_");
jPanel1.add(jLabel99, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 130, -1, -1));
jLabel100.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel100.setText("_");
jPanel1.add(jLabel100, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 130, -1, -1));
jLabel101.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel101.setText("_");
jPanel1.add(jLabel101, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 130, -1, -1));
jLabel102.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel102.setText("_");
jPanel1.add(jLabel102, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 130, -1, -1));
jLabel103.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel103.setText("_");
jPanel1.add(jLabel103, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 130, -1, -1));
jLabel104.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel104.setText("_");
jPanel1.add(jLabel104, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 130, -1, -1));
jLabel105.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel105.setText("_");
jPanel1.add(jLabel105, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 130, -1, -1));
jLabel106.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel106.setText("_");
jPanel1.add(jLabel106, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 130, -1, -1));
jLabel107.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel107.setText("_");
jPanel1.add(jLabel107, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 130, -1, -1));
jLabel108.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel108.setText("_");
jPanel1.add(jLabel108, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 130, -1, -1));
jLabel109.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel109.setText("_");
jPanel1.add(jLabel109, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 130, 10, -1));
jLabel110.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel110.setText("_");
jPanel1.add(jLabel110, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 130, 10, -1));
jLabel111.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel111.setText("_");
jPanel1.add(jLabel111, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 130, 10, -1));
jLabel112.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel112.setText("_");
jPanel1.add(jLabel112, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 130, 10, -1));
jLabel113.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel113.setText("_");
jPanel1.add(jLabel113, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 130, 10, -1));
jLabel114.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel114.setText("_");
jPanel1.add(jLabel114, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 130, 10, -1));
jLabel115.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel115.setText("_");
jPanel1.add(jLabel115, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 130, 10, -1));
jLabel116.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel116.setText("_");
jPanel1.add(jLabel116, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 130, 10, -1));
jLabel117.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel117.setText("_");
jPanel1.add(jLabel117, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 130, 10, -1));
jLabel118.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel118.setText("_");
jPanel1.add(jLabel118, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 130, 10, -1));
jLabel119.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel119.setText("_");
jPanel1.add(jLabel119, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 130, 10, -1));
jLabel120.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel120.setText("_");
jPanel1.add(jLabel120, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 130, 10, -1));
jLabel121.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel121.setText("_");
jPanel1.add(jLabel121, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 130, 10, -1));
jLabel122.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel122.setText("_");
jPanel1.add(jLabel122, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 130, 10, -1));
jLabel123.setFont(new java.awt.Font("Agency FB", 0, 24));
jLabel123.setText("_");
jPanel1.add(jLabel123, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 130, 10, -1));
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 709, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(21, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(Ahorcado, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Ahorcado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
this.jButton1.setEnabled(false);
this.C.PonerLetra(this.jButton1.getText().charAt(0),this.jButton1.getText(),this.jButton1.getText().charAt(0));
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
this.jButton2.setEnabled(false);
this.C.PonerLetra(this.jButton2.getText().charAt(0),this.jButton2.getText(),this.jButton2.getText().charAt(0));
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
this.jButton3.setEnabled(false);
this.C.PonerLetra(this.jButton3.getText().charAt(0),this.jButton3.getText(),this.jButton3.getText().charAt(0));
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
this.jButton4.setEnabled(false);
// TODO add your handling code here:
this.C.PonerLetra(this.jButton4.getText().charAt(0),this.jButton4.getText(),this.jButton4.getText().charAt(0));
}//GEN-LAST:event_jButton4ActionPerformed
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
// TODO add your handling code here:
this.jButton5.setEnabled(false);
this.C.PonerLetra(this.jButton5.getText().charAt(0),this.jButton5.getText(),this.jButton5.getText().charAt(0));
}//GEN-LAST:event_jButton5ActionPerformed
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
// TODO add your handling code here:
this.jButton6.setEnabled(false);
this.C.PonerLetra(this.jButton6.getText().charAt(0),this.jButton6.getText(),this.jButton6.getText().charAt(0));
}//GEN-LAST:event_jButton6ActionPerformed
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
this.jButton7.setEnabled(false);
// TODO add your handling code here:
this.C.PonerLetra(this.jButton7.getText().charAt(0),this.jButton7.getText(),this.jButton7.getText().charAt(0));
}//GEN-LAST:event_jButton7ActionPerformed
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
this.jButton8.setEnabled(false);
this.C.PonerLetra(this.jButton8.getText().charAt(0),this.jButton8.getText(),this.jButton8.getText().charAt(0));
}//GEN-LAST:event_jButton8ActionPerformed
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
this.jButton9.setEnabled(false);
this.C.PonerLetra(this.jButton9.getText().charAt(0),this.jButton9.getText(),this.jButton9.getText().charAt(0));
}//GEN-LAST:event_jButton9ActionPerformed
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
this.jButton10.setEnabled(false);
this.C.PonerLetra(this.jButton10.getText().charAt(0),this.jButton10.getText(),this.jButton10.getText().charAt(0));
}//GEN-LAST:event_jButton10ActionPerformed
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
// TODO add your handling code here:
this.jButton11.setEnabled(false);
this.C.PonerLetra(this.jButton11.getText().charAt(0),this.jButton11.getText(),this.jButton11.getText().charAt(0));
}//GEN-LAST:event_jButton11ActionPerformed
private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
this.jButton12.setEnabled(false);
this.C.PonerLetra(this.jButton12.getText().charAt(0),this.jButton12.getText(),this.jButton12.getText().charAt(0));
}//GEN-LAST:event_jButton12ActionPerformed
private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
// TODO add your handling code here:
this.jButton13.setEnabled(false);
this.C.PonerLetra(this.jButton13.getText().charAt(0),this.jButton13.getText(),this.jButton13.getText().charAt(0));
}//GEN-LAST:event_jButton13ActionPerformed
private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
// TODO add your handling code here:
this.jButton14.setEnabled(false);
this.C.PonerLetra(this.jButton14.getText().charAt(0),this.jButton14.getText(),this.jButton14.getText().charAt(0));
}//GEN-LAST:event_jButton14ActionPerformed
private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
// TODO add your handling code here:
this.jButton15.setEnabled(false);
this.C.PonerLetra(this.jButton15.getText().charAt(0),this.jButton15.getText(),this.jButton15.getText().charAt(0));
}//GEN-LAST:event_jButton15ActionPerformed
private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
// TODO add your handling code here:
this.jButton16.setEnabled(false);
this.C.PonerLetra(this.jButton16.getText().charAt(0),this.jButton16.getText(),this.jButton16.getText().charAt(0));
}//GEN-LAST:event_jButton16ActionPerformed
private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
// TODO add your handling code here:
this.jButton17.setEnabled(false);
this.C.PonerLetra(this.jButton17.getText().charAt(0),this.jButton17.getText(),this.jButton17.getText().charAt(0));
}//GEN-LAST:event_jButton17ActionPerformed
private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
// TODO add your handling code here:
this.jButton18.setEnabled(false);
this.C.PonerLetra(this.jButton18.getText().charAt(0),this.jButton18.getText(),this.jButton18.getText().charAt(0));
}//GEN-LAST:event_jButton18ActionPerformed
private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed
// TODO add your handling code here:
this.jButton19.setEnabled(false);
this.C.PonerLetra(this.jButton19.getText().charAt(0),this.jButton19.getText(),this.jButton19.getText().charAt(0));
}//GEN-LAST:event_jButton19ActionPerformed
private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton20ActionPerformed
// TODO add your handling code here:
this.jButton20.setEnabled(false);
this.C.PonerLetra(this.jButton20.getText().charAt(0),this.jButton20.getText(),this.jButton20.getText().charAt(0));
}//GEN-LAST:event_jButton20ActionPerformed
private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
// TODO add your handling code here:
this.jButton21.setEnabled(false);
this.C.PonerLetra(this.jButton21.getText().charAt(0),this.jButton21.getText(),this.jButton21.getText().charAt(0));
}//GEN-LAST:event_jButton21ActionPerformed
private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed
// TODO add your handling code here:
this.jButton22.setEnabled(false);
this.C.PonerLetra(this.jButton22.getText().charAt(0),this.jButton22.getText(),this.jButton22.getText().charAt(0));
}//GEN-LAST:event_jButton22ActionPerformed
private void jButton23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton23ActionPerformed
// TODO add your handling code here:
this.jButton23.setEnabled(false);
this.C.PonerLetra(this.jButton23.getText().charAt(0),this.jButton23.getText(),this.jButton23.getText().charAt(0));
}//GEN-LAST:event_jButton23ActionPerformed
private void jButton24ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton24ActionPerformed
// TODO add your handling code here:
this.jButton24.setEnabled(false);
this.C.PonerLetra(this.jButton24.getText().charAt(0),this.jButton24.getText(),this.jButton24.getText().charAt(0));
}//GEN-LAST:event_jButton24ActionPerformed
private void jButton25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton25ActionPerformed
// TODO add your handling code here:
this.jButton25.setEnabled(false);
this.C.PonerLetra(this.jButton25.getText().charAt(0),this.jButton25.getText(),this.jButton25.getText().charAt(0));
}//GEN-LAST:event_jButton25ActionPerformed
private void jButton26ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton26ActionPerformed
// TODO add your handling code here:
this.jButton26.setEnabled(false);
this.C.PonerLetra(this.jButton26.getText().charAt(0),this.jButton26.getText(),this.jButton26.getText().charAt(0));
}//GEN-LAST:event_jButton26ActionPerformed
private void jButton27ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton27ActionPerformed
// TODO add your handling code here:
this.jButton27.setEnabled(false);
this.C.PonerLetra(this.jButton27.getText().charAt(0),this.jButton27.getText(),this.jButton27.getText().charAt(0));
}//GEN-LAST:event_jButton27ActionPerformed
private void ReiniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReiniciarActionPerformed
try {
this.C.IniciarPartida();
} catch (SQLException ex) {
Logger.getLogger(VistaPart.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_ReiniciarActionPerformed
private void jButton28ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton28ActionPerformed
try {
// TODO add your handling code here:
this.C.Salir();
} catch (Exception ex) {
Logger.getLogger(VistaPart.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_jButton28ActionPerformed
private void AceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AceptarActionPerformed
// TODO add your handling code here:
this.C.GuardarPuntaje();
}//GEN-LAST:event_AceptarActionPerformed
public JTextField getJNombre() {
return JNombre;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(VistaPart.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(VistaPart.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(VistaPart.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(VistaPart.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new VistaPart().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton Aceptar;
private javax.swing.JPanel Ahorcado;
private javax.swing.JLabel ImagenLabel;
private javax.swing.JTextField JNombre;
private javax.swing.JLabel Mensaje;
private javax.swing.JLabel Nombre;
private javax.swing.JButton Reiniciar;
private javax.swing.JLabel Reloj;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton11;
private javax.swing.JButton jButton12;
private javax.swing.JButton jButton13;
private javax.swing.JButton jButton14;
private javax.swing.JButton jButton15;
private javax.swing.JButton jButton16;
private javax.swing.JButton jButton17;
private javax.swing.JButton jButton18;
private javax.swing.JButton jButton19;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton20;
private javax.swing.JButton jButton21;
private javax.swing.JButton jButton22;
private javax.swing.JButton jButton23;
private javax.swing.JButton jButton24;
private javax.swing.JButton jButton25;
private javax.swing.JButton jButton26;
private javax.swing.JButton jButton27;
private javax.swing.JButton jButton28;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel100;
private javax.swing.JLabel jLabel101;
private javax.swing.JLabel jLabel102;
private javax.swing.JLabel jLabel103;
private javax.swing.JLabel jLabel104;
private javax.swing.JLabel jLabel105;
private javax.swing.JLabel jLabel106;
private javax.swing.JLabel jLabel107;
private javax.swing.JLabel jLabel108;
private javax.swing.JLabel jLabel109;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel110;
private javax.swing.JLabel jLabel111;
private javax.swing.JLabel jLabel112;
private javax.swing.JLabel jLabel113;
private javax.swing.JLabel jLabel114;
private javax.swing.JLabel jLabel115;
private javax.swing.JLabel jLabel116;
private javax.swing.JLabel jLabel117;
private javax.swing.JLabel jLabel118;
private javax.swing.JLabel jLabel119;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel120;
private javax.swing.JLabel jLabel121;
private javax.swing.JLabel jLabel122;
private javax.swing.JLabel jLabel123;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel28;
private javax.swing.JLabel jLabel29;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel30;
private javax.swing.JLabel jLabel31;
private javax.swing.JLabel jLabel32;
private javax.swing.JLabel jLabel33;
private javax.swing.JLabel jLabel34;
private javax.swing.JLabel jLabel35;
private javax.swing.JLabel jLabel36;
private javax.swing.JLabel jLabel37;
private javax.swing.JLabel jLabel38;
private javax.swing.JLabel jLabel39;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel40;
private javax.swing.JLabel jLabel41;
private javax.swing.JLabel jLabel42;
private javax.swing.JLabel jLabel43;
private javax.swing.JLabel jLabel44;
private javax.swing.JLabel jLabel45;
private javax.swing.JLabel jLabel46;
private javax.swing.JLabel jLabel47;
private javax.swing.JLabel jLabel48;
private javax.swing.JLabel jLabel49;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel50;
private javax.swing.JLabel jLabel51;
private javax.swing.JLabel jLabel52;
private javax.swing.JLabel jLabel53;
private javax.swing.JLabel jLabel54;
private javax.swing.JLabel jLabel55;
private javax.swing.JLabel jLabel56;
private javax.swing.JLabel jLabel57;
private javax.swing.JLabel jLabel58;
private javax.swing.JLabel jLabel59;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel60;
private javax.swing.JLabel jLabel61;
private javax.swing.JLabel jLabel62;
private javax.swing.JLabel jLabel63;
private javax.swing.JLabel jLabel64;
private javax.swing.JLabel jLabel65;
private javax.swing.JLabel jLabel66;
private javax.swing.JLabel jLabel67;
private javax.swing.JLabel jLabel68;
private javax.swing.JLabel jLabel69;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel70;
private javax.swing.JLabel jLabel71;
private javax.swing.JLabel jLabel72;
private javax.swing.JLabel jLabel73;
private javax.swing.JLabel jLabel74;
private javax.swing.JLabel jLabel75;
private javax.swing.JLabel jLabel76;
private javax.swing.JLabel jLabel77;
private javax.swing.JLabel jLabel78;
private javax.swing.JLabel jLabel79;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel80;
private javax.swing.JLabel jLabel81;
private javax.swing.JLabel jLabel82;
private javax.swing.JLabel jLabel83;
private javax.swing.JLabel jLabel84;
private javax.swing.JLabel jLabel85;
private javax.swing.JLabel jLabel86;
private javax.swing.JLabel jLabel87;
private javax.swing.JLabel jLabel88;
private javax.swing.JLabel jLabel89;
private javax.swing.JLabel jLabel9;
private javax.swing.JLabel jLabel90;
private javax.swing.JLabel jLabel91;
private javax.swing.JLabel jLabel92;
private javax.swing.JLabel jLabel93;
private javax.swing.JLabel jLabel94;
private javax.swing.JLabel jLabel95;
private javax.swing.JLabel jLabel96;
private javax.swing.JLabel jLabel97;
private javax.swing.JLabel jLabel98;
private javax.swing.JLabel jLabel99;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
// End of variables declaration//GEN-END:variables
public void MostrarMensaje() {
JOptionPane.showMessageDialog(null, "Debe ingresar un Nombre para el Registro");
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Vista/VistaPart.java | Java | asf20 | 88,781 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Modelo;
import BD.ConexionDAO;
import bean.Conexion;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
/**
*
* @author USUARIO
*/
public class Record extends ConexionDAO{
private Vector Nombre;
private Vector Tiempo;
public Record() {
Nombre = new Vector();
Tiempo = new Vector();
}
public void MostrarRecordN1() throws SQLException {
int a =0;
this.Nombre.clear();
this.Tiempo.clear();
ResultSet Resultado1;
Resultado1 = Conexion.consultar("SELECT *FROM \"Jugador\" where \"Nivel\" = 1 order by \"Tiempo\" " );
while(Resultado1.next()){
this.Nombre.add(Resultado1.getString("Nombre"));
this.Tiempo.add(Resultado1.getString("Tiempo"));
}
}
public void MostrarRecordN2() throws SQLException {
int a =0;
this.Nombre.clear();
this.Tiempo.clear();
ResultSet Resultado1;
Resultado1 = Conexion.consultar("SELECT *FROM \"Jugador\" where \"Nivel\" = 2 order by \"Tiempo\" ");
while(Resultado1.next()){
this.Nombre.add(Resultado1.getString("Nombre"));
this.Tiempo.add(Resultado1.getString("Tiempo"));
}
}
public void MostrarRecordN3() throws SQLException {
int a =0;
this.Nombre.clear();
this.Tiempo.clear();
ResultSet Resultado1;
Resultado1 = Conexion.consultar("SELECT *FROM \"Jugador\" where \"Nivel\" = 3 order by \"Tiempo\" ");
while(Resultado1.next()){
this.Nombre.add(Resultado1.getString("Nombre"));
this.Tiempo.add(Resultado1.getString("Tiempo"));
}
}
public Vector getNombre() {
return Nombre;
}
public Vector getTiempo() {
return Tiempo;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Modelo/Record.java | Java | asf20 | 2,072 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Modelo;
import BD.ConexionDAO;
import bean.Conexion;
/**
*
* @author USUARIO
*/
public class RegistrarDAO extends ConexionDAO{
public RegistrarDAO(String Tabla, String Texto) {
boolean Resultado = Conexion.ejecutar(" INSERT INTO \""+Tabla+"\"( \"Id\", \"Texto\") VALUES (nextval('nombre_sequencia'), \'"+Texto+"\'); ");
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Modelo/RegistrarDAO.java | Java | asf20 | 487 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Modelo;
import BD.ConexionDAO;
import bean.Conexion;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Random;
/**
*
* @author Robert Alvarado
*/
public class ModPartidaDAO extends ConexionDAO {
private Random R = new Random();
public ModPartidaDAO() {
super();
}
public String BuscarPalabra_1() throws SQLException{
ResultSet Resultado1,Resultado2;
int Numero = 0;
Resultado1 = Conexion.consultar("SELECT *FROM \"Palabra_1\" ");
while(Resultado1.next()){
Numero++;
}
int Numero2 = R.nextInt(Numero)+1;
Resultado2 = Conexion.consultar(" SELECT *FROM \"Palabra_1\" ");
for (int h = 1; h <= Numero2; h++) {
Resultado2.next();
}
String Palabra_1 = Resultado2.getString("Texto");
return Palabra_1.toUpperCase();
}
public String BuscarPalabra_2() throws SQLException{
ResultSet Resultado1,Resultado2;
int Numero = 0;
Resultado1 = Conexion.consultar("SELECT *FROM \"Palabra_2\" ");
while(Resultado1.next()){
Numero++;
}
int Numero2 = R.nextInt(Numero)+1;
Resultado2 = Conexion.consultar(" SELECT *FROM \"Palabra_2\" ");
for (int h = 1; h <= Numero2; h++) {
Resultado2.next();
}
String Palabra_1 = Resultado2.getString("Texto");
return Palabra_1.toUpperCase();
}
public String BuscarPalabra_3() throws SQLException{
ResultSet Resultado1,Resultado2;
int Numero = 0;
Resultado1 = Conexion.consultar("SELECT *FROM \"Palabra_3\" ");
while(Resultado1.next()){
Numero++;
}
int Numero2 = R.nextInt(Numero)+1;
Resultado2 = Conexion.consultar(" SELECT *FROM \"Palabra_3\" ");
for (int h = 1; h <= Numero2; h++) {
Resultado2.next();
}
String Palabra_1 = Resultado2.getString("Texto");
return Palabra_1.toUpperCase();
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Modelo/ModPartidaDAO.java | Java | asf20 | 2,209 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Modelo;
import BD.ConexionDAO;
import bean.Conexion;
import java.sql.ResultSet;
import javax.swing.Timer;
/**
*
* @author Robert Alvarado
*/
public class Jugador extends ConexionDAO {
private String Tiempo;
private int Nivel;
private String Nombre;
public Jugador(String Nombre, int Nivel, String Tiempo) {
this.Nombre = Nombre;
this.Nivel = Nivel;
this.Tiempo = Tiempo;
this.GuardarPuntaje();
}
public void GuardarPuntaje(){
boolean Resultado = Conexion.ejecutar(" INSERT INTO \"Jugador\"( \"Id\", \"Nombre\", \"Nivel\", \"Tiempo\") VALUES (nextval('nombre_sequencia'),\' "+this.Nombre+" \' ,"
+ " "+this.Nivel+" , \' "+this.Tiempo+" \'); ");
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Modelo/Jugador.java | Java | asf20 | 898 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Modelo;
import java.sql.SQLException;
import java.util.Vector;
/**
*
* @author USUARIO
*/
public class ModPartida {
private Vector PalabraOri = new Vector();
private Vector PalabraOri2 = new Vector();
private Vector Posicion = new Vector();
private int Error = 0;
private int Acierto = 0;
private ModPartidaDAO MPD = new ModPartidaDAO();
public ModPartida() throws SQLException {
}
public void BuscarPalabra() throws SQLException {
this.PalabraOri.clear();
String Pal = null;
Pal = this.MPD.BuscarPalabra_1();
for (int a = 0; a < Pal.length(); a++) {
this.PalabraOri.add(Pal.charAt(a));
}
}
public void BuscarPalabra2() throws SQLException {
this.PalabraOri2.clear();
String Pal = null;
Pal = this.MPD.BuscarPalabra_2();
for (int a = 0; a < Pal.length(); a++) {
this.PalabraOri2.add(Pal.charAt(a));
}
}
public void BuscarPalabra3() throws SQLException {
this.PalabraOri2.clear();
String Pal = null;
Pal = this.MPD.BuscarPalabra_3();
for (int a = 0; a < Pal.length(); a++) {
this.PalabraOri2.add(Pal.charAt(a));
}
}
public Vector getPalabraOri() {
return PalabraOri;
}
public Vector getPalabraOri2() {
return PalabraOri2;
}
public void ContarError(){
this.Error++;
}
public int getError() {
return Error;
}
public void setError(int Error) {
this.Error = Error;
}
public int getAcierto() {
return Acierto;
}
public void setAcierto(int Acierto) {
this.Acierto = Acierto;
}
public boolean SeguirJugando() {
boolean resp = true;
if (this.Error < 8) {
resp = true;
} else {
resp = false;
}
return resp;
}
public boolean Gano() {
boolean resp = false;
if (this.PalabraOri.size() == this.Acierto) {
resp = true;
}
return resp;
}
public boolean Gano2() {
boolean resp = false;
if (this.PalabraOri2.size() == this.Acierto) {
resp = true;
}
return resp;
}
public boolean BuscarLetra(char c) {
boolean respuesta = false;
for (int i = 0; i < PalabraOri.size(); i++) {
if (c == PalabraOri.elementAt(i)) {
this.Acierto++;
this.Posicion.add(i + 1);
respuesta = true;
}
}
return respuesta;
}
public boolean BuscarLetra2(char c) {
boolean respuesta = false;
for (int i = 0; i < PalabraOri2.size(); i++) {
if (c == PalabraOri2.elementAt(i)) {
this.Acierto++;
this.Posicion.add(i + 1);
respuesta = true;
}
}
return respuesta;
}
public boolean BuscarLetraV(String c) {
boolean respuesta = false;
for (int i = 0; i < PalabraOri2.size(); i++) {
if (c == PalabraOri2.elementAt(i)) {
this.Acierto++;
this.Posicion.add(i + 1);
respuesta = true;
}
}
return respuesta;
}
public Vector getPosicion() {
return Posicion;
}
public void LimpiarPosicion() {
this.Posicion.clear();
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Modelo/ModPartida.java | Java | asf20 | 3,748 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Modelo;
/**
*
* @author Robert Alvarado
*/
public class Registrar {
public Registrar() {
}
public int Contar(String Frase){
int P = 0;
System.out.println(Frase.length());
for(int a = 0; a < Frase.length(); a++){
if(Frase.charAt(a) == ' '){
P++;
}
}
return P+1;
}
}
| 1-1-primer-proyecto | trunk/1-1-primer-proyecto/src/Modelo/Registrar.java | Java | asf20 | 521 |
//<![CDATA[
// Recent Post widget for Blogger with Preloader
// Author: Taufik Nurrohman
// https://plus.google.com/108949996304093815163/about
// Licence: Free for change, keep the original attribution, non commercial
function showRecentPosts(json) {
for (var i = 0; i < rp_numPosts; i++) {
if (i == json.feed.entry.length) break;
var entry = json.feed.entry[i],
postTitle = entry.title.$t,
postAuthor = entry.author[0].name.$t,
postDate = entry.published.$t.substring(0, 10),
postUrl,
linkTarget,
postContent,
postImage,
skeleton = "";
var dy = postDate.substring(0, 4),
dm = postDate.substring(5, 7),
dd = postDate.substring(8, 10);
for (var j = 0; j < entry.link.length; j++) {
if (entry.link[j].rel == 'alternate') {
postUrl = entry.link[j].href;
break;
}
}
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'replies' && entry.link[k].type == 'text/html') {
commentNum = entry.link[k].title.split(" ")[0];
commentLabel = entry.link[k].title.split(" ")[1];
break;
}
}
if ("content" in entry) {
postContent = entry.content.$t;
} else if ("summary" in entry) {
postContent = entry.summary.$t;
} else {
postContent = '';
}
if (rp_thumbWidth !== 0) {
if ("media$thumbnail" in entry) {
postImage = '<img style="width:' + rp_thumbWidth + 'px;height:' + rp_thumbWidth + 'px;" src="' + entry.media$thumbnail.url.replace(/\/s[0-9]+\-c/g, "\/s" + rp_thumbWidth + "-c") + '" alt="Loading..." />';
} else {
postImage = '<img style="width:' + rp_thumbWidth + 'px;height:' + rp_thumbWidth + 'px;" src="' + rp_noImage + '" alt="Loading..."/>';
}
} else {
postImage = "";
}
postContent = postContent.replace(/<br ?\/?>/ig, " ");
postContent = postContent.replace(/<\S[^>]*>/g, "");
if (postContent.length > rp_numChars) {
if (rp_numChars !== 0) {
postContent = postContent.substring(0, rp_numChars) + '…';
} else {
postContent = '';
}
}
linkTarget = (rp_newTabLink) ? ' target="_blank"' : '';
skeleton = '<li>';
skeleton += '<a href="' + postUrl + '"' + linkTarget + '>' + postImage + '</a>';
skeleton += '<div class="recent-right">';
skeleton += '<a class="title" href="' + postUrl + '"' + linkTarget + '>' + postTitle + '</a>';
skeleton += postContent;
skeleton += '</div>';
skeleton += '<br style="clear:both;"/><span class="foot"><span class="recent-date">' + dd + ' ' + rp_monthNames[parseInt(dm, 10) - 1] + ' ' + dy + '</span></span>';
skeleton += '</li>';
document.getElementById('recent-post').innerHTML += skeleton;
}
}
var labelName = (rp_sortByLabel !== false) ? '-/' + rp_sortByLabel : "";
var rp_script = document.createElement('script');
rp_script.src = rp_homePage + '/feeds/posts/default/' + labelName + '?alt=json-in-script&callback=showRecentPosts';
// Preloading...
if (rp_loadTimer === "onload") {
window.onload = function() {
document.getElementsByTagName('head')[0].appendChild(rp_script);
};
} else {
setTimeout(function() {
document.getElementsByTagName('head')[0].appendChild(rp_script);
}, rp_loadTimer);
}
//]]> | 123bloggerthemes | trunk/js/recent-post-preloader-by-taufik-nurrohman.js | JavaScript | gpl2 | 3,625 |
var JudNav = {};
//Pengambilan judul artikel melalui feed
function ambilJudNav(json) {
for (var i = 0; i < json.feed.entry.length; i++) {
var judul = json.feed.entry[i];
var data = "";
for (var k = 0; k < judul.link.length; k++) {
if (judul.link[k].rel == 'alternate') { data = judul.link[k].href; break } }
if (data != "") JudNav[data] = judul.title.$t } }
//Penulisan sekumpulan judul feed dengan mengambilnya dari fungsi sebelumnya 'ambilJudNav'
document.write('<script type="text/javascript" src="http://' + window.location.hostname + '/feeds/posts/summary?redirect=false&max-results=500&alt=json-in-script&callback=ambilJudNav"></' + 'script>');
//Pengambilan Anchor, Pengecekan URL dan Penggantian beberapa simbol
function JudulURL(anchor) {
var linkurl = anchor.match(/\/([^\/_]+)(_.*)?\.html/);
if (linkurl) {
linkurl = linkurl[1].replace(/-/g, " ");
linkurl = linkurl[0].toUpperCase() + linkurl.slice(1);
if (linkurl.length > 28) linkurl = linkurl.replace(/ [^ ]+$/, "...")
} return linkurl }
//Mengganti 'Posting Lama' dan 'Posting Lebih Baru'
$(window).load(function () {
window.setTimeout(function () {
var anchor = $("a.blog-pager-newer-link").attr("href");
if (anchor) { var judul = JudNav[anchor];
if (!judul) judul = JudulURL(anchor);
if (judul) $("a.blog-pager-newer-link").html(judul) }
anchor = $("a.blog-pager-older-link").attr("href");
if (anchor) { var judul = JudNav[anchor];
if (!judul) judul = JudulURL(anchor);
if (judul) $("a.blog-pager-older-link").html(judul)
} }, 500) }); | 123bloggerthemes | trunk/js/blogpager-judul.js | JavaScript | gpl2 | 1,532 |
//<![CDATA[
var thumbnail_mode = "float" ;
summary_noimg = 250;
summary_img = 210;
img_thumb_size = 95;
var numm_rand_post=3;
function removeHtmlTag(strx,chop){
if(strx.indexOf("<")!=-1){
var s = strx.split("<");
for(var i=0;i<s.length;i++){
if(s[i].indexOf(">")!=-1){
s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);
}
}
strx = s.join("");
}
chop = (chop < strx.length-1) ? chop : strx.length-2;
while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++;
strx = strx.substring(0,chop-1);
return strx+'...';
}
function createTumbnail(thumbUrl,img_size) {
var thumbnail = thumbUrl ;
var patt0 = /s72-c/g;
var patt1 = /s200/g;
var patt2 = /s320/g;
var patt3 = /s400/g;
var patt4 = /s640/g;
var patt5 = /s1600/g;
if ( patt1.test(thumbnail) == true) {
thumbnail = thumbnail.replace("s200","s"+img_size+"-c");
return thumbnail;
} else if (patt2.test(thumbnail) == true) {
thumbnail = thumbnail.replace("s320","s"+img_size+"-c");
return thumbnail;
} else if (patt3.test(thumbnail) == true) {
thumbnail = thumbnail.replace("s400","s"+img_size+"-c");
return thumbnail;
} else if (patt4.test(thumbnail) == true) {
thumbnail = thumbnail.replace("s640","s"+img_size+"-c");
return thumbnail;
} else if (patt5.test(thumbnail) == true) {
thumbnail = thumbnail.replace("s1600","s"+img_size+"-c");
return thumbnail;
} else if (patt0.test(thumbnail) == true) {
thumbnail = thumbnail.replace("s72-c","s"+img_size+"-c");
return thumbnail;
}
}
function popTumbnail(Turl,Tsize) {
return ('<img src="'+createTumbnail(Turl,Tsize)+'" />');
}
function createSummaryAndThumb(ID,pURL,pTitle){
var pID = 'summary' + ID;
var pThumb = 'thumbnail-' + ID;
var div = document.getElementById(pID);
var thumb = document.getElementById(pThumb);
var imgtag = "";
var img = div.getElementsByTagName("img");
var summ = summary_noimg;
if(img.length>=1) {
imgtag = '<span style="padding:0px;"><a href="'+ pURL +'" alt="tumbnail" title="'+ pTitle +'"><img src="' + img[0].src + '" alt="thumbnails"/></a></span>';
summ = summary_img;
} else {
imgtag = '';
summ = summary_img;
}
thumb.innerHTML = imgtag ;
div.innerHTML = '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>';
}
//]]> | 123bloggerthemes | trunk/js/thumbnail-summary-for-isotope.js | JavaScript | gpl2 | 2,478 |
$(document).ready(function() {
function filterPath(string) {
return string
.replace(/^\//,'')
.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
.replace(/\/$/,'');
}
var locationPath = filterPath(location.pathname);
var scrollElem = scrollableElement('html', 'body');
$('a[href*=#]').each(function() {
var thisPath = filterPath(this.pathname) || locationPath;
if ( locationPath == thisPath
&& (location.hostname == this.hostname || !this.hostname)
&& this.hash.replace(/#/,'') ) {
var $target = $(this.hash), target = this.hash;
if (target) {
var targetOffset = $target.offset().top;
$(this).click(function(event) {
event.preventDefault();
$(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
location.hash = target;
});
});
}
}
});
// use the first element that is "scrollable"
function scrollableElement(els) {
for (var i = 0, argLength = arguments.length; i <argLength; i++) {
var el = arguments[i],
$scrollElement = $(el);
if ($scrollElement.scrollTop()> 0) {
return el;
} else {
$scrollElement.scrollTop(1);
var isScrollable = $scrollElement.scrollTop()> 0;
$scrollElement.scrollTop(0);
if (isScrollable) {
return el;
}
}
}
return [];
}
}); | 123bloggerthemes | trunk/js/smooth-page-scroll-1.js | JavaScript | gpl2 | 1,449 |
//<![CDATA[
$(document).ready(function() {
function getTargetTop(elem){
var id = elem.attr("href");
var offset = 60;
return $(id).offset().top - offset;
}
$('a[href^="#"]').click(function(event) {
var target = getTargetTop($(this));
$('html, body').animate({scrollTop:target}, 1200);
event.preventDefault();
});
var sections = $('a[href^="#"]');
function checkSectionSelected(scrolledTo){
var threshold = 200;
var i;
for (i = 0; i < sections.length; i++) {
var section = $(sections[i]);
var target = getTargetTop(section);
if (scrolledTo > target - threshold && scrolledTo < target + threshold) {
sections.removeClass("active");
section.addClass("active");
} } ;}
checkSectionSelected($(window).scrollTop());
$(window).scroll(function(e){
checkSectionSelected($(window).scrollTop())
}); });
//]]> | 123bloggerthemes | trunk/js/smooth-page-scroll-2.js | JavaScript | gpl2 | 823 |
<script src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js" type="text/javascript"></script>
<script src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
<link
rel="exhibit/data"
type="application/jsonp"
href="https://spreadsheets.google.com/feeds/list/0Asy9DLkAdegIdHpQQmxxSFM5NjZaSVFEbks4bUlvcnc/od5/public/basic?alt=json-in-script"
ex:converter="googleSpreadsheets" /> | 123bible | trunk/src/javascript/tl_all.js | JavaScript | gpl3 | 461 |
/*** credits:
http://people.csail.mit.edu/dfhuynh/projects/timeline-exhibit/filtered-sources.js
***/
Timeline.FilteredEventSource = function(baseEventSource, match) {
this._baseEventSource = baseEventSource;
this._match = match;
this._events = new SimileAjax.EventIndex();
this._listeners = [];
var self = this;
this._eventListener = {
onAddMany: function() { console.log("here"); self._onAddMany(); },
onClear: function() { self._onClear(); }
}
this._baseEventSource.addListener(this._eventListener);
if (this._baseEventSource.getCount() > 0) {
this._onAddMany();
}
};
Timeline.FilteredEventSource.prototype.addListener = function(listener) {
this._listeners.push(listener);
};
Timeline.FilteredEventSource.prototype.removeListener = function(listener) {
for (var i = 0; i < this._listeners.length; i++) {
if (this._listeners[i] == listener) {
this._listeners.splice(i, 1);
break;
}
}
};
Timeline.FilteredEventSource.prototype.getEvent = function(id) {
return this._events.getEvent(id);
};
Timeline.FilteredEventSource.prototype.getEventIterator = function(startDate, endDate) {
return this._events.getIterator(startDate, endDate);
};
Timeline.FilteredEventSource.prototype.getEventReverseIterator = function(startDate, endDate) {
return this._events.getReverseIterator(startDate, endDate);
};
Timeline.FilteredEventSource.prototype.getAllEventIterator = function() {
return this._events.getAllIterator();
};
Timeline.FilteredEventSource.prototype.getCount = function() {
return this._events.getCount();
};
Timeline.FilteredEventSource.prototype.getEarliestDate = function() {
return this._events.getEarliestDate();
};
Timeline.FilteredEventSource.prototype.getLatestDate = function() {
return this._events.getLatestDate();
};
Timeline.FilteredEventSource.prototype._fire = function(handlerName, args) {
for (var i = 0; i < this._listeners.length; i++) {
var listener = this._listeners[i];
if (handlerName in listener) {
try {
listener[handlerName].apply(listener, args);
} catch (e) {
SimileAjax.Debug.exception(e);
}
}
}
};
Timeline.FilteredEventSource.prototype._onAddMany = function() {
this._events.removeAll();
var i = this._baseEventSource.getAllEventIterator();
while (i.hasNext()) {
var evt = i.next();
if (this._match(evt)) {
this._events.add(evt);
}
}
this._fire("onAddMany", []);
};
Timeline.FilteredEventSource.prototype._onClear = function() {
this._events.removeAll();
this._fire("onClear", []);
};
| 123bible | trunk/src/javascript/filtered-sources.js | JavaScript | gpl3 | 2,949 |
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAATTj_4YkZuaihAx0kvqq_3RT5TQ_3V3oDWogljA9hi5DEPPK3KBSMksPojdd95A7CAZ1r7YjmZTs36g"
type="text/javascript"></script>
<script type="text/javascript" src="http://timemap.googlecode.com/svn/tags/2.0/lib/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://timemap.googlecode.com/svn/tags/2.0/lib/mxn/mxn.js?(google)"></script>
<script type="text/javascript" src="http://timemap.googlecode.com/svn/tags/2.0/lib/timeline-1.2.js"></script>
<script src="http://timemap.googlecode.com/svn/tags/2.0/src/timemap.js" type="text/javascript"></script>
<script src="http://timemap.googlecode.com/svn/tags/2.0/src/param.js" type="text/javascript"></script>
<script src="http://timemap.googlecode.com/svn/tags/2.0/src/loaders/json.js" type="text/javascript"></script>
<script src="http://timemap.googlecode.com/svn/tags/2.0/src/loaders/google_spreadsheet.js" type="text/javascript"></script>
<script type="text/javascript">
var tm;
$(function() {
tm = TimeMap.init({
mapId: "map", // Id of map div element (required)
timelineId: "timeline", // Id of timeline div element (required)
options: {
eventIconPath: "http://timemap.googlecode.com/svn/tags/2.0/images/"
},
datasets: [
{
title: "Events",
id: "events",
theme: "purple",
type: "gss",
options: {
// lon/lat->ll=
key: "0Asy9DLkAdegIdGpENjRxSEU5VnItNzJMUU16R2NmT3c",
// map spreadsheet column names to expected ids
paramMap: {
start: "start",
end: "end"
},
// load extra data from non-standard spreadsheet columns
extraColumns: [
"time",
"place",
"author",
"remarks"
],
// let's do something with that extra data!
infoTemplate: "<table style='quarrytable'>" +
"<tr><th colspan='2' class='title'>Details</th></tr>" +
"<tr><th>Book</th><td>{{title}}</td></tr>" +
"<tr><th>Desc.</th><td>{{description}}</td></tr>" +
"<tr><th>Time</th><td>{{time}}</td></tr>" +
"<tr><th>Place</th><td>{{place}}</td></tr>" +
"<tr><th>Author</th><td>{{author}}</td></tr>" +
"<tr><th>Remarks</th><td>{{remarks}}</td></tr>" +
"</table>"
}
}
],
bandIntervals: [
Timeline.DateTime.YEAR,
Timeline.DateTime.DECADE
],
scrollTo: "0064"
});
});
</script>
<link href="http://timemap.googlecode.com/svn/tags/2.0/examples/examples.css" type="text/css" rel="stylesheet"/>
<style>
div#timelinecontainer{
width: 100%;
height: 40%;
}
div#timeline{
width: 100%;
height: 100%;
font-size: 12px;
background: #CCCCCC;
}
div#mapcontainer {
width: 100%;
height: 60%;
}
#timemap {
height: 650px;
}
div#map {
width: 100%;
height: 100%;
background: #EEEEEE;
}
div.infodescription {
font-style: normal;
width: 300px;
}
</style> | 123bible | trunk/src/javascript/tm_booksnt.js | JavaScript | gpl3 | 3,775 |
/*** add the following contect in the html header section:
<http://123bible.googlecode.com/svn/trunk/src/html/tl_nt_header.html>
***/
function constructFilteredEventSource(baseEventSource, database, propertyID, matchValue) {
return new Timeline.FilteredEventSource(
baseEventSource,
function(evt) {
return database.getObject(evt.getID(), propertyID) == matchValue;
}
);
}
function myTimelineConstructor(div, eventSource) {
var theme = Timeline.ClassicTheme.create();
theme.ether.backgroundColors[2] = theme.ether.backgroundColors[0];
theme.ether.backgroundColors[3] = theme.ether.backgroundColors[1];
var d = Timeline.DateTime.parseGregorianDateTime("-0175")
var bandInfos = [
Timeline.createBandInfo({
width: "20%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "a"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "30%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "b"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "30%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "c"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "20%",
overview: true,
intervalUnit: Timeline.DateTime.MILLENNIUM,
intervalPixels: 200,
eventSource: eventSource,
date: d,
theme: theme
})
];
bandInfos[1].syncWith = 0;
bandInfos[2].syncWith = 0;
bandInfos[3].syncWith = 1;
bandInfos[3].highlight = true;
div.style.height = "600px";
div.style.fontSize = "16px";
return Timeline.create(div, bandInfos, Timeline.HORIZONTAL);
}
| 123bible | trunk/src/javascript/tl_nt.js | JavaScript | gpl3 | 2,844 |
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAATTj_4YkZuaihAx0kvqq_3RT5TQ_3V3oDWogljA9hi5DEPPK3KBSMksPojdd95A7CAZ1r7YjmZTs36g"
type="text/javascript"></script>
<script type="text/javascript" src="http://timemap.googlecode.com/svn/tags/2.0/lib/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://timemap.googlecode.com/svn/tags/2.0/lib/mxn/mxn.js?(google)"></script>
<script type="text/javascript" src="http://timemap.googlecode.com/svn/tags/2.0/lib/timeline-1.2.js"></script>
<script src="http://timemap.googlecode.com/svn/tags/2.0/src/timemap.js" type="text/javascript"></script>
<script src="http://timemap.googlecode.com/svn/tags/2.0/src/param.js" type="text/javascript"></script>
<script src="http://timemap.googlecode.com/svn/tags/2.0/src/loaders/json.js" type="text/javascript"></script>
<script src="http://timemap.googlecode.com/svn/tags/2.0/src/loaders/google_spreadsheet.js" type="text/javascript"></script>
<script type="text/javascript">
var tm;
$(function() {
tm = TimeMap.init({
mapId: "map", // Id of map div element (required)
timelineId: "timeline", // Id of timeline div element (required)
options: {
eventIconPath: "http://timemap.googlecode.com/svn/tags/2.0/images/"
},
datasets: [
{
title: "Events",
id: "events",
theme: "purple",
type: "gss",
options: {
// lon/lat->ll=
key: "0Asy9DLkAdegIdGFmdW1oc1YyQzBPS3pONjFoQmpXWUE",
// map spreadsheet column names to expected ids
paramMap: {
start: "start",
end: "end"
}
}
}
],
bandIntervals: [
Timeline.DateTime.YEAR,
Timeline.DateTime.DECADE
],
scrollTo: "0044"
});
});
</script>
<link href="http://timemap.googlecode.com/svn/tags/2.0/examples/examples.css" type="text/css" rel="stylesheet"/>
<style>
div#timelinecontainer{
width: 100%;
height: 40%;
}
div#timeline{
width: 100%;
height: 100%;
font-size: 12px;
background: #CCCCCC;
}
div#mapcontainer {
width: 100%;
height: 60%;
}
#timemap {
height: 650px;
}
div#map {
width: 100%;
height: 100%;
background: #EEEEEE;
}
div.infodescription {
font-style: normal;
width: 300px;
}
</style> | 123bible | trunk/src/javascript/tm_paul.js | JavaScript | gpl3 | 2,711 |
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"></script>
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
<!--script type="text/javascript" src="http://people.csail.mit.edu/dfhuynh/projects/timeline-exhibit/filtered-sources.js"></script-->
<link rel="exhibit/data" type="application/jsonp"
href="https://spreadsheets.google.com/feeds/list/0Asy9DLkAdegIdElDU2pETlVCR0l0VFFTdFJXdEhkQVE/od6/public/basic?alt=json-in-script"
ex:converter="googleSpreadsheets" />
<script>
function constructFilteredEventSource(baseEventSource, database, propertyID, matchValue) {
return new Timeline.FilteredEventSource(
baseEventSource,
function(evt) {
return database.getObject(evt.getID(), propertyID) == matchValue;
}
);
}
function myTimelineConstructor(div, eventSource) {
var theme = Timeline.ClassicTheme.create();
theme.ether.backgroundColors[2] = theme.ether.backgroundColors[0];
theme.ether.backgroundColors[3] = theme.ether.backgroundColors[1];
var d = Timeline.DateTime.parseGregorianDateTime("-0175")
var bandInfos = [
Timeline.createBandInfo({
width: "20%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "a"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "30%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "b"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "30%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "c"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "20%",
overview: true,
intervalUnit: Timeline.DateTime.MILLENNIUM,
intervalPixels: 200,
eventSource: eventSource,
date: d,
theme: theme
})
];
bandInfos[1].syncWith = 0;
bandInfos[2].syncWith = 0;
bandInfos[3].syncWith = 1;
bandInfos[3].highlight = true;
div.style.height = "600px";
div.style.fontSize = "16px";
return Timeline.create(div, bandInfos, Timeline.HORIZONTAL);
}
</script>
<script>
<!--http://people.csail.mit.edu/dfhuynh/projects/timeline-exhibit/filtered-sources.js-->
Timeline.FilteredEventSource = function(baseEventSource, match) {
this._baseEventSource = baseEventSource;
this._match = match;
this._events = new SimileAjax.EventIndex();
this._listeners = [];
var self = this;
this._eventListener = {
onAddMany: function() { console.log("here"); self._onAddMany(); },
onClear: function() { self._onClear(); }
}
this._baseEventSource.addListener(this._eventListener);
if (this._baseEventSource.getCount() > 0) {
this._onAddMany();
}
};
Timeline.FilteredEventSource.prototype.addListener = function(listener) {
this._listeners.push(listener);
};
Timeline.FilteredEventSource.prototype.removeListener = function(listener) {
for (var i = 0; i < this._listeners.length; i++) {
if (this._listeners[i] == listener) {
this._listeners.splice(i, 1);
break;
}
}
};
Timeline.FilteredEventSource.prototype.getEvent = function(id) {
return this._events.getEvent(id);
};
Timeline.FilteredEventSource.prototype.getEventIterator = function(startDate, endDate) {
return this._events.getIterator(startDate, endDate);
};
Timeline.FilteredEventSource.prototype.getEventReverseIterator = function(startDate, endDate) {
return this._events.getReverseIterator(startDate, endDate);
};
Timeline.FilteredEventSource.prototype.getAllEventIterator = function() {
return this._events.getAllIterator();
};
Timeline.FilteredEventSource.prototype.getCount = function() {
return this._events.getCount();
};
Timeline.FilteredEventSource.prototype.getEarliestDate = function() {
return this._events.getEarliestDate();
};
Timeline.FilteredEventSource.prototype.getLatestDate = function() {
return this._events.getLatestDate();
};
Timeline.FilteredEventSource.prototype._fire = function(handlerName, args) {
for (var i = 0; i < this._listeners.length; i++) {
var listener = this._listeners[i];
if (handlerName in listener) {
try {
listener[handlerName].apply(listener, args);
} catch (e) {
SimileAjax.Debug.exception(e);
}
}
}
};
Timeline.FilteredEventSource.prototype._onAddMany = function() {
this._events.removeAll();
var i = this._baseEventSource.getAllEventIterator();
while (i.hasNext()) {
var evt = i.next();
if (this._match(evt)) {
this._events.add(evt);
}
}
this._fire("onAddMany", []);
};
Timeline.FilteredEventSource.prototype._onClear = function() {
this._events.removeAll();
this._fire("onClear", []);
};
</script>
| 123bible | trunk/src/nt.js | JavaScript | gpl3 | 6,492 |
<script src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js" type="text/javascript"></script>
<script src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
<link
rel="exhibit/data"
type="application/jsonp"
href="https://spreadsheets.google.com/feeds/list/0Asy9DLkAdegIdHpQQmxxSFM5NjZaSVFEbks4bUlvcnc/od6/public/basic?alt=json-in-script"
ex:converter="googleSpreadsheets" /> | 123bible | trunk/src/js/tl_all.js | JavaScript | gpl3 | 468 |
<!-- header section insert begin -->
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"></script>
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
<script type="text/javascript" src="http://123bible.googlecode.com/svn/trunk/src/javascript/filtered-sources.js"></script>
<script type="text/javascript" src="http://123bible.googlecode.com/svn/trunk/src/javascript/tl_nt.js"></script>
<link rel="exhibit/data" type="application/jsonp"
href="https://spreadsheets.google.com/feeds/list/0Asy9DLkAdegIdElDU2pETlVCR0l0VFFTdFJXdEhkQVE/od6/public/basic?alt=json-in-script"
ex:converter="googleSpreadsheets" />
<!-- header section insert end -->
| 123bible | trunk/src/html/tl_nt_header.html | HTML | gpl3 | 777 |
<div ex:role="coder" ex:coderclass="Color" id="textColors">
<span ex:color="purple">聖經人物</span>
<span ex:color="#993366">西方人物</span>
<span ex:color="#3366FF">世界歷史</span>
<span ex:color="#996666">中国人物</span>
<span ex:color="#009966">中国歷史</span>
</div>
<table width=100% cellspacing=10><tr><td width=90%>
<div
ex:role="view"
ex:viewClass="Timeline"
ex:timelineConstructor="myTimelineConstructor"
ex:start=".start"
ex:end=".end"
ex:colorKey=".eventType"
ex:colorCoder="textColors">
</div>
<div ex:role="lens">
<b ex:content=".label"></b>
<p><img ex:if-exists=".image" ex:src-content=".image" /></p>
<p ex:content=".description"></p>
</div>
</td><td valign=top>
<br><div ex:role="facet" ex:facetClass="TextSearch" ex:facetLabel="搜索/Search"></div>
<br><div ex:role="facet" ex:expression=".eventType" ex:facetLabel="選項/Select"></div>
</td></tr></table>
| 123bible | trunk/src/html/tl_nt.html | HTML | gpl3 | 964 |
<!-- header section insert begin -->
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"></script>
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
<script type="text/javascript" src="http://123bible.googlecode.com/svn/trunk/src/javascript/filtered-sources.js"></script>
<script type="text/javascript" src="http://123bible.googlecode.com/svn/trunk/sandbox/timeline/tl_all.js"></script>
<!-- source #1: nt data -->
<link rel="exhibit/data" type="application/jsonp"
href="https://spreadsheets.google.com/feeds/list/0Asy9DLkAdegIdElDU2pETlVCR0l0VFFTdFJXdEhkQVE/od6/public/basic?alt=json-in-script"
ex:converter="googleSpreadsheets" />
<!-- source #2: additional historic data -->
<link
rel="exhibit/data"
type="application/jsonp"
href="https://spreadsheets.google.com/feeds/list/0Asy9DLkAdegIdHpQQmxxSFM5NjZaSVFEbks4bUlvcnc/od5/public/basic?alt=json-in-script"
ex:converter="googleSpreadsheets" />
<!-- header section insert end -->
| 123bible | trunk/src/html/tl_all_header.html | HTML | gpl3 | 1,088 |
<div id="timemap">
<div id="timelinecontainer">
<div id="timeline"></div>
</div>
<div id="mapcontainer">
<div id="map"></div>
</div>
</div> | 123bible | trunk/src/html/tm_booksnt.html | HTML | gpl3 | 174 |
<div id="timemap">
<div id="timelinecontainer">
<div id="timeline"></div>
</div>
<div id="mapcontainer">
<div id="map"></div>
</div>
</div> | 123bible | trunk/src/html/tm_paul.html | HTML | gpl3 | 174 |
<table width=100% cellspacing=10><tr><td width=90%>
<div ex:role="view"
ex:viewClass="Timeline"
ex:start=".start"
ex:end=".end"
/*ex:caption=".caption"
ex:color=".color"
ex:classname=".classname"*/
ex:colorKey=".eventType">
</div>
<div ex:role="lens">
<b ex:content=".label"></b>
<p><img ex:if-exists=".image" ex:src-content=".image" /></p>
<p ex:content=".description"></p>
</div>
</td><td valign=top>
<br><div ex:role="facet" ex:facetClass="TextSearch" ex:facetLabel="搜尋/Search"></div>
<br><div ex:role="facet" ex:expression=".eventType" ex:facetLabel="選項/Select"></div>
</td></tr></table> | 123bible | trunk/src/html/tl_all.html | HTML | gpl3 | 647 |
/*** The following is required in the html header section:
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"></script>
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
<script type="text/javascript" src="<same url to this javascript>/filtered-sources.js"></script>
<link rel="exhibit/data" type="application/jsonp"
href="https://spreadsheets.google.com/feeds/list/0Asy9DLkAdegIdHpQQmxxSFM5NjZaSVFEbks4bUlvcnc/od6/public/basic?alt=json-in-script"
ex:converter="googleSpreadsheets" />
***/
function constructFilteredEventSource(baseEventSource, database, propertyID, matchValue) {
return new Timeline.FilteredEventSource(
baseEventSource,
function(evt) {
return database.getObject(evt.getID(), propertyID) == matchValue;
}
);
}
function myTimelineConstructor(div, eventSource) {
var theme = Timeline.ClassicTheme.create();
theme.ether.backgroundColors[2] = theme.ether.backgroundColors[0];
theme.ether.backgroundColors[3] = theme.ether.backgroundColors[1];
var d = Timeline.DateTime.parseGregorianDateTime("-0175")
var bandInfos = [
Timeline.createBandInfo({
width: "20%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "a"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "30%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "b"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "30%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "c"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "20%",
overview: true,
intervalUnit: Timeline.DateTime.MILLENNIUM,
intervalPixels: 200,
eventSource: eventSource,
date: d,
theme: theme
})
];
bandInfos[1].syncWith = 0;
bandInfos[2].syncWith = 0;
bandInfos[3].syncWith = 1;
bandInfos[3].highlight = true;
div.style.height = "600px";
div.style.fontSize = "16px";
return Timeline.create(div, bandInfos, Timeline.HORIZONTAL);
}
| 123bible | trunk/sandbox/timeline/tl_all.js | JavaScript | gpl3 | 3,407 |
/***
<!--Add the following to html header section: -->
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"></script>
<script type="text/javascript" src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
<script type="text/javascript" src="<same url to this javascript>/filtered-sources.js"></script>
<link rel="exhibit/data" type="application/jsonp"
href="https://spreadsheets.google.com/feeds/list/0Asy9DLkAdegIdElDU2pETlVCR0l0VFFTdFJXdEhkQVE/od6/public/basic?alt=json-in-script"
ex:converter="googleSpreadsheets" />
***/
function constructFilteredEventSource(baseEventSource, database, propertyID, matchValue) {
return new Timeline.FilteredEventSource(
baseEventSource,
function(evt) {
return database.getObject(evt.getID(), propertyID) == matchValue;
}
);
}
function myTimelineConstructor(div, eventSource) {
var theme = Timeline.ClassicTheme.create();
theme.ether.backgroundColors[2] = theme.ether.backgroundColors[0];
theme.ether.backgroundColors[3] = theme.ether.backgroundColors[1];
var d = Timeline.DateTime.parseGregorianDateTime("-0175")
var bandInfos = [
Timeline.createBandInfo({
width: "20%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "a"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "30%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "b"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "30%",
intervalUnit: Timeline.DateTime.CENTURY,
intervalPixels: 100,
eventSource: constructFilteredEventSource(eventSource, window.database, "category", "c"),
date: d,
theme: theme
}),
Timeline.createBandInfo({
width: "20%",
overview: true,
intervalUnit: Timeline.DateTime.MILLENNIUM,
intervalPixels: 200,
eventSource: eventSource,
date: d,
theme: theme
})
];
bandInfos[1].syncWith = 0;
bandInfos[2].syncWith = 0;
bandInfos[3].syncWith = 1;
bandInfos[3].highlight = true;
div.style.height = "600px";
div.style.fontSize = "16px";
return Timeline.create(div, bandInfos, Timeline.HORIZONTAL);
}
| 123bible | trunk/sandbox/timeline/tl_nt.js | JavaScript | gpl3 | 3,308 |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Transport
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
}
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Transport/Main.cs | C# | asf20 | 469 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
namespace Main.Transport
{
public enum EtatsConnexion
{
ConnexionEtablie,
EnAttente
}
public class Connexion
{
private static List<Connexion> listeConnexions = new List<Connexion>();
private byte idConnexionLogique;
private EtatsConnexion etat;
private byte applicationId;
private byte adresseDestination;
private Timer timer;
private List<string> data;
private Connexion(byte applicationId, byte adresseDestination)
{
if (listeConnexions.Count > 0)
this.idConnexionLogique = (byte)(listeConnexions.Max(c => c.idConnexionLogique) + 1);
else
this.idConnexionLogique = 1;
this.etat = EtatsConnexion.EnAttente;
this.applicationId = applicationId;
this.adresseDestination = adresseDestination;
}
public byte IdConnexionLogique { get { return idConnexionLogique; } }
public EtatsConnexion Etat { get { return etat; } set { etat = value; } }
public byte ApplicationId { get { return applicationId; } }
public byte AdresseDestination { get { return adresseDestination; } }
public static List<Connexion> ListeConnexions { get { return listeConnexions.ToList(); } }
public List<string> Data { get { return data; } set { data = value; } }
public static Connexion GetConnexion(byte applicationId, byte adresseDestination)
{
Connexion connexion = listeConnexions.Find(c => c.applicationId == applicationId && c.adresseDestination == adresseDestination);
if (connexion == null)
{
connexion = new Connexion(applicationId, adresseDestination);
listeConnexions.Add(connexion);
}
return connexion;
}
public static Connexion GetConnexion(byte idConnexionLogique)
{
Connexion connexion = listeConnexions.Find(c => c.idConnexionLogique == idConnexionLogique);
return connexion;
}
public void Destroy()
{
listeConnexions.Remove(this);
}
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Transport/ConnexionTransport.cs | C# | asf20 | 2,365 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("Transport")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Transport")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("56b7f05a-63ae-4354-b2ee-7db7fc848ba6")]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Transport/Properties/AssemblyInfo.cs | C# | asf20 | 1,551 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Core;
using Transport.Properties;
using Core.Packets;
using System.IO;
using Core.PrimitivesCommunication;
using System.IO.Pipes;
namespace Transport
{
static class Program
{
static Main consoleMain;
/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
consoleMain = new Main();
consoleMain.Show();
List<PDUSession> listeLigne = PDUSession.ReadFichier(Resources.S_LECTURE);
foreach (PDUSession ligne in listeLigne)
{
Connexion connexion = Connexion.GetConnexion(ligne.ApplicationId, ligne.AddresseDestination);
if(connexion.Etat == EtatsConnexion.EnAttente)
{
Primitive connexionReq = Primitive.CreateNConnectReq(connexion.IdConnexionLogique, connexion.AdresseDestination);
using (NamedPipeServerStream sw = new NamedPipeServerStream(REGLES.GetPipeTransportToReseau("0"), PipeDirection.Out))
{
connexionReq.WriteJson(sw);
}
}
}
using (NamedPipeServerStream sr = new NamedPipeServerStream(REGLES.GetPipeTransportToReseau("0"), PipeDirection.In))
{
Primitive pr = Primitive.ReadJson(sr);
}
//Packet[] paquet = Packet.CreateDataPackets(54, 2, 3, "Salut ici michael Roussel c'est un supel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici michel c'est un super test Salut ici micher test Salut ici michael Roussel c'est un super test Salut ici michael Roussel c'est un super test Salut ici michael Roussel c'est un super test Salut ici michael Roussel c'est un super test Salut ici michael Roussel c'est un super test");
//paquet.GetStringOfBitArray();
//REGLES.GetPipeTransportToReseau(ebhgjkbaegawe_
}
static void RequestConnection(PDUSession ligne)
{
}
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Transport/Program.cs | C# | asf20 | 2,674 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Main.PrimitivesCommunication;
using System.IO.Pipes;
using System.Threading;
using Core.Connexions;
namespace Main.Transport
{
class CoucheTransport
{
public NamedPipeServerStream pipeTransportToReseau;
public NamedPipeClientStream pipeReseauToTransport;
/// <summary>
/// Méthode s'occupant d'envoyer les réponses de session à la couche réseau sous
/// forme de primitives
/// </summary>
public void EcrireVersReseau()
{
pipeTransportToReseau = new NamedPipeServerStream(REGLES.PIPE_TRANSPORT_TO_RESEAU);
StreamWriter streamWriterTransportToReseau = new StreamWriter(pipeTransportToReseau);
Console.WriteLine("Attente de connexion sur le pipe TRANSPORT_TO_RESEAU");
pipeTransportToReseau.WaitForConnection();
streamWriterTransportToReseau.AutoFlush = true;
byte applicationId;
byte addresseDestination;
string data;
string[] argsSession;
string transactionSession = String.Empty;
ConnexionTransport ConnexionTransport;
//lecture du fichier session
Console.WriteLine("Debut : Lecture de S_LECTURE");
using (StreamReader sr = new StreamReader(REGLES.S_LECTURE))
{
while ((transactionSession = sr.ReadLine()) != null)
{
Console.WriteLine("\tLigne lue dans S_LECTURE : " + transactionSession);
argsSession = transactionSession.Split(';');
applicationId = Convert.ToByte(argsSession[0]);
addresseDestination = Convert.ToByte(argsSession[1]);
data = transactionSession;
byte adresseSource = applicationId;
byte adresseDestination;
adresseSource = applicationId;
do
{
adresseDestination = GenererAdresse();
} while (ConnexionReseau.ListeConnexions.Any(c => c.AdresseDestination == adresseDestination));
ConnexionTransport = ConnexionTransport.GetConnexion(applicationId, adresseSource, addresseDestination);
ConnexionTransport.Data.Enqueue(data);
if (ConnexionTransport.Etat == EtatsConnexion.AttenteConnexion)
{
//Envoi de la primitive vers réseau
Primitive connexionReq = Primitive.CreateNConnectReq(ConnexionTransport.IdConnexionLogique, ConnexionTransport.AdresseSource, ConnexionTransport.AdresseDestination);
Console.WriteLine("\tEnvoi vers Reseau : " + connexionReq.ToString());
connexionReq.Send(streamWriterTransportToReseau);
ConnexionTransport.Etat = EtatsConnexion.AttenteConfirmation;
}
TraiterReponse(streamWriterTransportToReseau);
}
}
Console.WriteLine("Fin : Lecture de S_LECTURE");
//Tant qu'il reste des connexions
while (ConnexionTransport.ListeConnexions.Count > 0)
{
TraiterReponse(streamWriterTransportToReseau);
Thread.Sleep(50);
}
}
/// <summary>
/// Méthode s'occupant de traiter les réponses
/// </summary>
public void TraiterReponse(StreamWriter sw)
{
List<ConnexionTransport> listeConnexions = ConnexionTransport.ListeConnexions.Where(c => c.Etat == EtatsConnexion.ConnexionEtablie).ToList();
Primitive primitiveAEnvoyer;
string lineIdConnexion = String.Empty;
foreach (ConnexionTransport connexionTransport in listeConnexions)
{
//Tant qu'il y a des données à envoyer on les envois
while(connexionTransport.Data.Count > 0)
{
primitiveAEnvoyer = Primitive.CreateNDataReq(connexionTransport.IdConnexionLogique, connexionTransport.Data.Dequeue());
Console.WriteLine("Traitement de la connexion #" + connexionTransport.IdConnexionLogique+"\n\tEnvoi de donnees : " + primitiveAEnvoyer.ToString());
primitiveAEnvoyer.Send(sw);
}
//Lorsqu'il n'y a plus rien à envoyer on envoi une demande de déconnexion
primitiveAEnvoyer = Primitive.CreateNDisconnectReq(connexionTransport.IdConnexionLogique);
connexionTransport.Etat = EtatsConnexion.AttenteConfirmation;
Console.WriteLine("\tFin des donnees : " + primitiveAEnvoyer.ToString());
primitiveAEnvoyer.Send(sw);
}
}
/// <summary>
/// Méthode exécutée par un thread s'occupant de lire les primitives venant de la couche réseau
/// </summary>
public void LireDeReseau()
{
pipeReseauToTransport = new NamedPipeClientStream(REGLES.PIPE_RESEAU_TO_TRANSPORT);
StreamReader streamReaderReseauToTransport = new StreamReader(pipeReseauToTransport);
pipeReseauToTransport.Connect();
Console.WriteLine("Lire de Reseau : connecte au pipe RESEAU_TO_TRANSPORT");
ConnexionTransport connection;
Primitive primitiveRecu = null;
string ligneReseau;
while (true)
{
ligneReseau = streamReaderReseauToTransport.ReadLine();
if (ligneReseau != null)
{
primitiveRecu = Primitive.Receive(ligneReseau);
Console.WriteLine("Primitive recue : " + primitiveRecu.ToString());
connection = ConnexionTransport.GetConnexion(primitiveRecu.AdresseReponse);
if (connection != null)
{
//on traite les primitives reçues
switch (primitiveRecu.PrimitiveType)
{
case PrimitiveTypes.NConnectConfirmation:
connection.Etat = EtatsConnexion.ConnexionEtablie;
break;
case PrimitiveTypes.NDisconnectIndication:
connection.Destroy();
break;
}
}
//Écriture des réponses envoyé
using (StreamWriter sw = new StreamWriter(REGLES.S_ECRITURE, true))
{
sw.WriteLine(primitiveRecu.ToString());
}
}
}
}
/// <summary>
/// Méthode s'occupant de générer une addresse
/// </summary>
public byte GenererAdresse()
{
Random rand = new Random();
return (byte)rand.Next(1, 249);
}
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Transport/CoucheTransport.cs | C# | asf20 | 7,431 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("Transport")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Transport")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("56b7f05a-63ae-4354-b2ee-7db7fc848ba6")]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Transport/Properties/AssemblyInfo.cs | C# | asf20 | 1,551 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Transport.Properties;
using System.IO;
using System.IO.Pipes;
using Main.Transport;
using System.Threading;
using Main;
using Core.Connexions;
namespace Transport
{
static class Program
{
static Thread threadLireDeReseau;
/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
static void Main()
{
//On supprime les fichiers qui peuvent contenir des données d'une exécution précédente
File.Delete(REGLES.S_ECRITURE);
//Instanciation des threads et démarrage
CoucheTransport coucheTransport = new CoucheTransport();
threadLireDeReseau = new Thread(coucheTransport.LireDeReseau);
Console.WriteLine("Demarrage : Lire de Reseau");
threadLireDeReseau.Start();
//Démarrage de la méthode à être exécutée par le processus principal
Console.WriteLine("Demarrage : Ecrire vers Reseau");
coucheTransport.EcrireVersReseau();
//On attend que le canal soit vide de toutes données avant d'arrêter les threads
Console.WriteLine("Attente que le pipe TRANSPORT_TO_RESEAU soit vide");
coucheTransport.pipeTransportToReseau.WaitForPipeDrain();
threadLireDeReseau.Abort();
//Déconnexion et fermeture des canaux
coucheTransport.pipeReseauToTransport.Dispose();
coucheTransport.pipeTransportToReseau.Disconnect();
coucheTransport.pipeTransportToReseau.Close();
Console.WriteLine("Simulation terminee, appuyez sur une touche pour quitter...");
Console.ReadKey();
Environment.Exit(0);
}
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Transport/Program.cs | C# | asf20 | 1,889 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Main
{
/// <summary>
/// Énumération des raisons pour un paquet ou une primitive d'indication de libération.
/// None dans le cas d'un paquet ou une primitive de demande de libération.
/// </summary>
public enum Raisons
{
None,
DistantRefuse,
FournisseurRefuse
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Core/Raisons.cs | C# | asf20 | 439 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using Newtonsoft.Json;
using System.IO.Pipes;
using Main.Packets;
using System.Threading;
namespace Main.PrimitivesCommunication
{
/// <summary>
/// Primitive de communication entre couche transport et couche réseau
/// </summary>
public class Primitive
{
#region Attributs
private PrimitiveTypes primitiveType;
private byte idConnexion;
private byte adresseSource;
private byte adresseDestination;
private byte adresseReponse;
private string donneesUtilisateur;
private Raisons raison;
#endregion
#region Constructeurs
private Primitive() { }
private Primitive(PrimitiveTypes primitive, byte idConnexion, byte adresseSource, byte adresseDestination, byte adresseReponse)
{
this.idConnexion = idConnexion;
this.primitiveType = primitive;
this.adresseSource = adresseSource;
this.adresseDestination = adresseDestination;
this.adresseReponse = adresseReponse;
}
private Primitive(PrimitiveTypes primitive, byte idConnexion, string donneesUtilisateur)
{
this.idConnexion = idConnexion;
this.primitiveType = primitive;
this.donneesUtilisateur = donneesUtilisateur;
}
private Primitive(PrimitiveTypes primitive, byte adresseReponse)
{
this.primitiveType = primitive;
this.adresseReponse = adresseReponse;
}
private Primitive(PrimitiveTypes primitive, byte adresseReponse, Raisons raison)
{
this.primitiveType = primitive;
this.adresseReponse = adresseReponse;
this.raison = raison;
}
#endregion
#region Propriétés
public Int16 Size
{
get
{
Int16 retour;
switch(primitiveType)
{
case PrimitivesCommunication.PrimitiveTypes.NConnectConfirmation:
case PrimitivesCommunication.PrimitiveTypes.NConnectResponse:
case PrimitivesCommunication.PrimitiveTypes.NDisconnectRequest:
retour = 1;
break;
case PrimitivesCommunication.PrimitiveTypes.NConnectRequest:
case PrimitivesCommunication.PrimitiveTypes.NConnectIndication:
case PrimitivesCommunication.PrimitiveTypes.NDisconnectIndication:
retour = 2;
break;
case PrimitivesCommunication.PrimitiveTypes.NDataRequest:
case PrimitivesCommunication.PrimitiveTypes.NDataIndication:
retour = 16;
break;
default:
throw new NotImplementedException();
}
return retour;
}
}
public byte IdConnexion { get { return idConnexion; } set { idConnexion = value; } }
public byte AdresseSource { get { return adresseSource; } set { adresseSource = value; } }
public byte AdresseDestination { get { return adresseDestination; } set { adresseDestination = value; } }
public byte AdresseReponse { get { return adresseReponse; } set { adresseReponse = value; } }
public string DonneesUtilisateur { get { return donneesUtilisateur; } set { donneesUtilisateur = value; } }
public Raisons Raison { get { return raison; } set { raison = value; } }
public PrimitiveTypes PrimitiveType { get { return primitiveType; } set { primitiveType = value; } }
#endregion
#region Méthodes de création des primitives
/// <summary>
/// Instanciation d'une primitive NConnectRequest
/// </summary>
static public Primitive CreateNConnectReq(byte idConnexion, byte adresseSource, byte adresseDestination)
{
return new Primitive(PrimitiveTypes.NConnectRequest, idConnexion, adresseSource, adresseDestination, 0);
}
/// <summary>
/// Instanciation d'une primitive NConnectIndication (Jamais utilisé puisque le système b est simulé)
/// </summary>
static public Primitive CreateNConnectInd(byte idConnexion, byte adresseSource, byte adresseDestination)
{
return new Primitive(PrimitiveTypes.NConnectIndication, idConnexion, adresseSource, adresseDestination, 0);
}
/// <summary>
/// Instanciation d'une primitive NConnectResponse (Jamais utilisé puisque le système b est simulé)
/// </summary>
static public Primitive CreateNConnectResp(byte adresseReponse)
{
return new Primitive(PrimitiveTypes.NConnectResponse, adresseReponse);
}
/// <summary>
/// Instanciation d'une primitive NConnectConfirmation
/// </summary>
static public Primitive CreateNConnectConf(byte adresseReponse)
{
return new Primitive(PrimitiveTypes.NConnectConfirmation, adresseReponse);
}
/// <summary>
/// Instanciation d'une primitive NDataRequest
/// </summary>
static public Primitive CreateNDataReq(byte idConnexion, string donneesUtilisateur)
{
return new Primitive(PrimitiveTypes.NDataRequest, idConnexion, donneesUtilisateur);
}
/// <summary>
/// Instanciation d'une primitive NDataIndication (Jamais utilisé puisque le système b est simulé)
/// </summary>
static public Primitive CreateNDataInd(byte idConnexion, string donneesUtilisateur)
{
return new Primitive(PrimitiveTypes.NDataIndication, idConnexion, donneesUtilisateur);
}
/// <summary>
/// Instanciation d'une primitive NDisconnectRequest
/// </summary>
static public Primitive CreateNDisconnectReq(byte adresseReponse)
{
return new Primitive(PrimitiveTypes.NDisconnectRequest, adresseReponse);
}
/// <summary>
/// Instanciation d'une primitive NDisconnectIndication
/// </summary>
static public Primitive CreateNDisconnectInd(byte adresseReponse, Raisons raison)
{
return new Primitive(PrimitiveTypes.NDisconnectIndication, adresseReponse, raison);
}
#endregion
#region Méthodes d'envoie et de réception des primitives entre les couches.
/// <summary>
/// Envoie la primitive dans le flux passé en paramètre
/// </summary>
/// <param name="sw"></param>
public void Send(StreamWriter sw)
{
sw.WriteLine(JsonConvert.SerializeObject(this));
}
/// <summary>
/// Instancie une primitive à partir d'un flux passé en paramètre
/// </summary>
/// <param name="sr"></param>
/// <returns></returns>
public static Primitive Receive(StreamReader sr)
{
Primitive p = null;
string str = sr.ReadLine();
if(!String.IsNullOrEmpty(str))
p = JsonConvert.DeserializeObject<Primitive>(str) as Primitive;
return p;
}
/// <summary>
/// Instancie une primitive à partir d'une ligne reçu d'une couche supérieure ou inférieure
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static Primitive Receive(string str)
{
return JsonConvert.DeserializeObject<Primitive>(str) as Primitive;
}
#endregion
public override string ToString()
{
string toString = Enum.GetName(typeof(PrimitiveTypes), primitiveType);
if (this.primitiveType == PrimitiveTypes.NConnectRequest || this.primitiveType == PrimitiveTypes.NConnectIndication)
toString += (" Source : " + this.adresseSource + " Destination : " + this.adresseDestination);
else if (this.primitiveType == PrimitiveTypes.NConnectResponse || this.primitiveType == PrimitiveTypes.NConnectConfirmation || this.primitiveType == PrimitiveTypes.NDisconnectRequest)
toString += (" Adresse reponse : " + this.adresseReponse);
else if (this.primitiveType == PrimitiveTypes.NDisconnectIndication)
toString += (" Adresse reponse : " + this.adresseReponse + " Raison : " + this.raison);
else if (this.primitiveType == PrimitiveTypes.NConnectResponse || this.primitiveType == PrimitiveTypes.NConnectConfirmation || this.primitiveType == PrimitiveTypes.NDataRequest)
toString += (" Données utilisateurs : " + this.donneesUtilisateur);
return toString;
}
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Core/PrimitivesCommunication/Primitive.cs | C# | asf20 | 9,234 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Main.PrimitivesCommunication
{
/// <summary>
/// Énumération des types de primitive
/// </summary>
public enum PrimitiveTypes
{
NConnectRequest = 11,
NConnectIndication,
NConnectResponse,
NConnectConfirmation = 15,
NDataRequest,
NDataIndication,
NDisconnectRequest,
NDisconnectIndication = 19
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Core/PrimitivesCommunication/PrimitiveTypes.cs | C# | asf20 | 509 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Core.Connexions
{
/// <summary>
/// Énumération des états possible pour les connexions (transport et réseau).
/// </summary>
public enum EtatsConnexion
{
ConnexionEtablie,
AttenteConnexion,
AttenteConfirmation,
EnDeconnexion
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Core/Connexions/EtatsConnexion.cs | C# | asf20 | 407 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using Main.Packets;
using System.IO;
using Main;
namespace Core.Connexions
{
public class ConnexionReseau
{
private static List<ConnexionReseau> listeConnexions = new List<ConnexionReseau>();
private bool pretATransmettre;
private byte idConnexionTransport;
private byte idConnexionLogique;
private EtatsConnexion etat;
private byte adresseSource;
private byte adresseDestination;
private int pr;
private int ps;
private List<DataPacket> dataPacketsWaiting = new List<DataPacket>();
private Timer timer;
private bool timerElapsed;
private ConnexionReseau(byte idConnexionTransport, byte adresseSource, byte adresseDestination)
{
if (listeConnexions.Count > 0)
this.idConnexionLogique = (byte)(listeConnexions.Max(c => c.idConnexionLogique) + 1);
else
this.idConnexionLogique = 1;
this.idConnexionTransport = idConnexionTransport;
this.etat = EtatsConnexion.AttenteConnexion;
this.adresseSource = adresseSource;
this.adresseDestination = adresseDestination;
this.pr = 0;
this.ps = 7;
this.pretATransmettre = true;
this.timerElapsed = false;
timer = new Timer(REGLES.DELAI_TEMPORISATEUR);
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
}
#region Propriétés
public bool PretATransmettre { get { return pretATransmettre && dataPacketsWaiting.Count > 0; } }
public byte IdConnexionTransport { get { return idConnexionTransport; } }
public byte IdConnexionLogique { get { return idConnexionLogique; } }
public EtatsConnexion Etat { get { return etat; } set { etat = value; } }
public byte AdresseSource { get { return adresseSource; } }
public byte AdresseDestination { get { return adresseDestination; } }
public static List<ConnexionReseau> ListeConnexions { get { return listeConnexions.ToList(); } }
public bool TimerElapsed { get { return timerElapsed; } }
public int CurrentPS { get { return ps; } }
public int NextPS
{
get
{
if (ps < 7)
ps++;
else
ps = 0;
return ps;
}
}
public int CurrentPR { get { return pr; } }
public int NextPR
{
get
{
if (pr < 7)
pr++;
else
pr = 0;
return pr;
}
}
#endregion
/// <summary>
/// Ajoute un paquet de données à la file des paquets de données en attente d'envoie
/// </summary>
/// <param name="dataPacket"></param>
public void AddDataPacketWaiting(DataPacket dataPacket)
{
dataPacketsWaiting.Add(dataPacket);
}
/// <summary>
/// Obtient le prochain paquet en attente dans la file.
/// </summary>
/// <returns></returns>
public DataPacket GetFirstDataPacketWaiting()
{
if (dataPacketsWaiting.Any())
return dataPacketsWaiting[0];
return null;
}
/// <summary>
/// Supprime le prochain paquet en attente dans la file.
/// </summary>
/// <param name="dataPacket"></param>
public void DeleteFirstDataPacketWaiting(DataPacket dataPacket)
{
if (dataPacketsWaiting.Any())
dataPacketsWaiting.RemoveAt(0);
}
/// <summary>
/// Méthode qui retourne une connexion réseau selon les paramètres idConnexionTransport, adresseSource et adresseDestination.
/// </summary>
/// <returns>Retourne la connexion existante si existe déjà ou sinon une nouvelle connexion</returns>
public static ConnexionReseau GetConnexion(byte idConnexionTransport, byte adresseSource, byte adresseDestination)
{
ConnexionReseau connexion = listeConnexions.Find(c => c.adresseSource == adresseSource && c.adresseDestination == adresseDestination);
if (connexion == null)
{
connexion = new ConnexionReseau(idConnexionTransport, adresseSource, adresseDestination);
listeConnexions.Add(connexion);
}
return connexion;
}
/// <summary>
/// Méthode qui retourne une connexion réseau selon le paramètre idConnexionTransport.
/// </summary>
/// <returns>Retourne la connexion existante si existe. Sinon, retourne null</returns>
public static ConnexionReseau GetConnexionFromTransport(byte idConnexionTransport)
{
ConnexionReseau connexion = listeConnexions.Find(c => c.idConnexionTransport == idConnexionTransport);
return connexion;
}
/// <summary>
/// Méthode qui retourne une connexion réseau selon le paramètre idConnexionLogique.
/// </summary>
/// <returns>Retourne la connexion existante si existe. Sinon, retourne null</returns>
public static ConnexionReseau GetConnexionFromReseau(byte idConnexionLogique)
{
ConnexionReseau connexion = listeConnexions.Find(c => c.idConnexionLogique == idConnexionLogique);
return connexion;
}
/// <summary>
/// Simule l'envoie vers la couche liaison et éventuellement du système b et simulation de la réponse du système b.
/// </summary>
/// <param name="packetEnvoye">Le paquet qui est envoyé vers la couche inférieure (liaison)</param>
public Packet EnvoieVersLiaison(Packet packetEnvoye)
{
Packet packetRecu = null; //Le paquet qui est reçu de la couche liaison en réponse au paquet envoyé.
//Écriture dans le fichier L_ECRITURE (envoie vers liaison).
using (StreamWriter sw = new StreamWriter(REGLES.L_ECRITURE, true))
{
packetEnvoye.Send(sw);
}
//Début de la simulation de la réponse du système b selon l'envoie.
switch (packetEnvoye.PacketType.Type)
{
case PacketTypes.ConnectionRequestPacket:
ConnectionPacket connectionPacketEnvoye = (ConnectionPacket)packetEnvoye;
this.etat = EtatsConnexion.AttenteConfirmation;
if ((connectionPacketEnvoye.AdresseSource % REGLES.MULTIPLE_POUR_REFUS_CONNEXION_DISTANT) == 0)
{
packetRecu = FreeConnectionPacket.CreateFreeConnectionIndicationPacket(connectionPacketEnvoye.NumeroConnexion, connectionPacketEnvoye.AdresseDestination, connectionPacketEnvoye.AdresseSource, Raisons.DistantRefuse);
}
else if (!((connectionPacketEnvoye.AdresseSource % REGLES.MULTIPLE_POUR_ABSENCE_REPONSE_CONNEXION) == 0))
{
packetRecu = ConnectionPacket.CreateConnectionConfirmationPacket(connectionPacketEnvoye.NumeroConnexion, connectionPacketEnvoye.AdresseDestination, connectionPacketEnvoye.AdresseSource);
}
else
{
timer.Start();
}
break;
case PacketTypes.DataPacket:
DataPacket dataPacketEnvoye = (DataPacket)packetEnvoye;
if (!((this.adresseSource % REGLES.MULTIPLE_POUR_ABSENCE_ACQUITTEMENT) == 0))
{
int packetPs = Convert.ToInt32(dataPacketEnvoye.PacketType.Bits4To2, 2);
if (AquittementNegatif(packetPs))
{
packetRecu = AcknowledgementPacket.CreateNegativeAcknowledgementPacket(idConnexionLogique, packetPs);
if (dataPacketEnvoye.NombreRetransmission < REGLES.FENETRE_ENVOIE_PACKET)
pretATransmettre = true;
else
pretATransmettre = false;
dataPacketEnvoye.IncrementerNombreRetransmissions();
}
else
{
dataPacketsWaiting.RemoveAt(0);
pretATransmettre = true;
EnvoieSystemeBVersLiaison(AcknowledgementPacket.CreatePositiveAcknowledgementPacket(idConnexionLogique, packetPs + 1));
}
}
else
{
pretATransmettre = false;
timerElapsed = false;
timer.Start();
}
break;
case PacketTypes.FreeConnectionPacket:
FreeConnectionPacket freeConnectionPacket = (FreeConnectionPacket)packetEnvoye;
packetRecu = FreeConnectionPacket.CreateFreeConnectionIndicationPacket(freeConnectionPacket.NumeroConnexion, freeConnectionPacket.AdresseDestination, freeConnectionPacket.AdresseSource, Raisons.DistantRefuse);
break;
}
EnvoieSystemeBVersLiaison(packetRecu);
return packetRecu;
}
/// <summary>
/// Écrit dans le fichier L_LECTURE le paquet que le système b aurait retourné.
/// </summary>
/// <param name="p"></param>
private void EnvoieSystemeBVersLiaison(Packet p)
{
if (p != null)
{
using (StreamWriter sw = new StreamWriter(REGLES.L_LECTURE, true))
{
ConnexionReseau connReseau = ConnexionReseau.GetConnexionFromReseau(p.NumeroConnexion);
if (!((connReseau.AdresseSource % REGLES.MULTIPLE_POUR_ABSENCE_REPONSE_CONNEXION) == 0))
p.Send(sw);
}
}
}
/// <summary>
/// Détermine si l'aquittement est négatif
/// </summary>
private bool AquittementNegatif(int ps)
{
Random rand = new Random();
int randNbr = rand.Next(0, 7);
return (ps == randNbr);
}
/// <summary>
/// Détruit la connexion. (Enlève la connexion de la liste de connexions static).
/// </summary>
public void Destroy()
{
timer.Dispose();
listeConnexions.Remove(this);
}
/// <summary>
/// Se produit lorsque le temps du temporisateur est écoulé
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void timer_Elapsed(object sender, ElapsedEventArgs e)
{
if (this.etat == EtatsConnexion.ConnexionEtablie)
{
if (dataPacketsWaiting[0].NombreRetransmission < REGLES.FENETRE_ENVOIE_PACKET)
pretATransmettre = true;
dataPacketsWaiting[0].IncrementerNombreRetransmissions();
}
timerElapsed = true;
timer.Stop();
}
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Core/Connexions/ConnexionReseau.cs | C# | asf20 | 11,801 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
namespace Core.Connexions
{
public class ConnexionTransport
{
private static List<ConnexionTransport> listeConnexions = new List<ConnexionTransport>(); //Liste de connexion transport
private byte idConnexionLogique; //Id de connexion transport
private EtatsConnexion etat; //État de la connexion transport
private byte applicationId; //Id de l'application qui utilise cette connexion
private byte adresseSource; //Adresse source de cette connexion
private byte adresseDestination; //Adresse destination de cette connexion
private Queue<string> data; //File de données en attente d'être envoyées
private ConnexionTransport(byte applicationId, byte adresseSource, byte adresseDestination)
{
if (listeConnexions.Count > 0)
this.idConnexionLogique = (byte)(listeConnexions.Max(c => c.idConnexionLogique) + 1);
else
this.idConnexionLogique = 1;
this.etat = EtatsConnexion.AttenteConnexion;
this.applicationId = applicationId;
this.adresseSource = adresseSource;
this.adresseDestination = adresseDestination;
this.data = new Queue<string>();
}
#region Propriétés
public static List<ConnexionTransport> ListeConnexions { get { return listeConnexions.ToList(); } }
public byte IdConnexionLogique { get { return idConnexionLogique; } }
public EtatsConnexion Etat { get { return etat; } set { etat = value; } }
public byte ApplicationId { get { return applicationId; } }
public byte AdresseSource { get { return adresseSource; } }
public byte AdresseDestination { get { return adresseDestination; } }
public Queue<string> Data { get { return data; } set { data = value; } }
#endregion
/// <summary>
/// Méthode qui retourne une connexion transport selon les paramètres applicationId, adresseSource et adresseDestination.
/// </summary>
/// <returns>Retourne la connexion existante si existe déjà ou sinon une nouvelle connexion</returns>
public static ConnexionTransport GetConnexion(byte applicationId, byte adresseSource, byte adresseDestination)
{
ConnexionTransport connexion = listeConnexions.Find(c => c.applicationId == applicationId && c.adresseDestination == adresseDestination);
if (connexion == null)
{
connexion = new ConnexionTransport(applicationId, adresseSource, adresseDestination);
listeConnexions.Add(connexion);
}
return connexion;
}
/// <summary>
/// Méthode qui retourne une connexion transport selon le paramètre adresseReponse.
/// </summary>
/// <returns>Retourne la connexion existante si existe. Sinon, retourne null</returns>
public static ConnexionTransport GetConnexion(byte adresseReponse)
{
ConnexionTransport connexion = listeConnexions.Find(c => c.idConnexionLogique == adresseReponse);
return connexion;
}
/// <summary>
/// Détruit la connexion. (Enlève la connexion de la liste de connexions static).
/// </summary>
public void Destroy()
{
listeConnexions.Remove(this);
}
}
}
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Core/Connexions/ConnexionTransport.cs | C# | asf20 | 3,670 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Core")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("b8d64042-95d8-4b14-b759-d0446cbe1970")]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 028490q38u532895uy92hf98jh98shfe98sehgesg | trunk/Apres/Source/Core/Properties/AssemblyInfo.cs | C# | asf20 | 1,541 |