Commit a4bc77fc authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Bug fixing and integration of SubBitmap and Font into the translation system

parent 5de95d2f
...@@ -109,6 +109,14 @@ ERROR_NBFRAMES_TITLE|Invalid number of frames ...@@ -109,6 +109,14 @@ ERROR_NBFRAMES_TITLE|Invalid number of frames
ERROR_NBFRAMES_MSG|The number of frames cannot be smaller than 1 ERROR_NBFRAMES_MSG|The number of frames cannot be smaller than 1
ERROR_OTF_TITLE|OTF not supported ERROR_OTF_TITLE|OTF not supported
ERROR_OTF_MSG|You have chosen an OpenType font, VLC will display it correctly but the Skin Editor can not display it.\nYou will see another font in the preview. ERROR_OTF_MSG|You have chosen an OpenType font, VLC will display it correctly but the Skin Editor can not display it.\nYou will see another font in the preview.
ERROR_SIZE_INVALID_TITLE|Invalid size
ERROR_SIZE_INVALID_MSG|Please enter a valid size.
ERROR_WIDTH_INVALID_TITLE|Invalid width
ERROR_WIDTH_INVALID_MSG|Please enter a valid width.
ERROR_HEIGHT_INVALID_TITLE|Invalid heiht
ERROR_HEIGHT_INVALID_MSG|Please enter a valid height.
ERROR_OUTSIDE_TITLE|Dimensions not valid
ERROR_OUTSIDE_MSG|Specified dimensions are outside the parent bitmap!
#Other strings #Other strings
THEMEINFO_NAME_DEFAULT|Unnamed Theme THEMEINFO_NAME_DEFAULT|Unnamed Theme
......
...@@ -9,6 +9,8 @@ WIN_ITEM_ID|ID*: ...@@ -9,6 +9,8 @@ WIN_ITEM_ID|ID*:
WIN_ITEM_ID_TIP|Name and identificator of the %t. Must be unique. WIN_ITEM_ID_TIP|Name and identificator of the %t. Must be unique.
WIN_ITEM_X|X: WIN_ITEM_X|X:
WIN_ITEM_Y|Y: WIN_ITEM_Y|Y:
WIN_ITEM_WIDTH|Width:
WIN_ITEM_HEIGHT|Height:
WIN_ITEM_VISIBLE|Visibility: WIN_ITEM_VISIBLE|Visibility:
FILE_INDIR|in the same folder as the XML file FILE_INDIR|in the same folder as the XML file
...@@ -27,6 +29,10 @@ WIN_BITMAP_FPS_TIP|Only used in animated bitmaps; it is the number of frames (im ...@@ -27,6 +29,10 @@ WIN_BITMAP_FPS_TIP|Only used in animated bitmaps; it is the number of frames (im
WIN_BITMAP_ANIMATION|Animation attributes WIN_BITMAP_ANIMATION|Animation attributes
WIN_BITMAP_CHOOSER_TITLE|Choose alphacolor WIN_BITMAP_CHOOSER_TITLE|Choose alphacolor
#SubBitmap
WIN_SBMP_TITLE|SubBitmap settings
WIN_SBMP_BOUNDS|Position and dimension attributes
#Font #Font
WIN_FONT_TITLE|Font settings WIN_FONT_TITLE|Font settings
WIN_FONT_FILE|File*: WIN_FONT_FILE|File*:
......
...@@ -376,6 +376,7 @@ public class Layout implements ActionListener{ ...@@ -376,6 +376,7 @@ public class Layout implements ActionListener{
/** /**
* Handles the user interaction with the editing dialog. * Handles the user interaction with the editing dialog.
*/ */
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(ok_btn)) { if(e.getSource().equals(ok_btn)) {
if(id_tf.getText().equals("")) { if(id_tf.getText().equals("")) {
...@@ -388,11 +389,11 @@ public class Layout implements ActionListener{ ...@@ -388,11 +389,11 @@ public class Layout implements ActionListener{
return; return;
} }
} }
if(width_tf.getText().length()>0 && Integer.parseInt(width_tf.getText())<=0) { if(width_tf.getText().length()<1 || Integer.parseInt(width_tf.getText())<=0) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_WIDTH_INVALID_MSG"),Language.get("ERROR_WIDTH_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame,Language.get("ERROR_WIDTH_INVALID_MSG"),Language.get("ERROR_WIDTH_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
if(height_tf.getText().length()>0 && Integer.parseInt(height_tf.getText())<=0) { if(height_tf.getText().length()<1 || Integer.parseInt(height_tf.getText())<=0) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_HEIGHT_INVALID_MSG"),Language.get("ERROR_HEIGHT_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame,Language.get("ERROR_HEIGHT_INVALID_MSG"),Language.get("ERROR_HEIGHT_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
......
...@@ -520,7 +520,7 @@ public class Skin implements ActionListener{ ...@@ -520,7 +520,7 @@ public class Skin implements ActionListener{
public java.awt.Font getFont(String id) { public java.awt.Font getFont(String id) {
if(id.equals("defaultfont")) { if(id.equals("defaultfont")) {
return (new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,12)); return (new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,12));
} }
Resource r = getResource(id); Resource r = getResource(id);
if(r==null) return (new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,12)); if(r==null) return (new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,12));
try { try {
......
...@@ -284,6 +284,7 @@ public class Window implements ActionListener{ ...@@ -284,6 +284,7 @@ public class Window implements ActionListener{
frame.setVisible(true); frame.setVisible(true);
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(ok_btn)) { if(e.getSource().equals(ok_btn)) {
if(id_tf.getText().equals("")) { if(id_tf.getText().equals("")) {
......
...@@ -71,7 +71,7 @@ public class Bitmap extends ImageResource implements ActionListener{ ...@@ -71,7 +71,7 @@ public class Bitmap extends ImageResource implements ActionListener{
if(e.hasAttribute("file")) file = e.getAttribute("file"); if(e.hasAttribute("file")) file = e.getAttribute("file");
if(e.hasAttribute("alphacolor")) alphacolor = e.getAttribute("alphacolor"); if(e.hasAttribute("alphacolor")) alphacolor = e.getAttribute("alphacolor");
if(e.hasAttribute("nbframes")) nbframes = Integer.valueOf(e.getAttribute("nbframes")); if(e.hasAttribute("nbframes")) nbframes = Integer.valueOf(e.getAttribute("nbframes"));
if(e.hasAttribute("fps")) fps = Integer.valueOf(e.getAttribute("fps")); if(e.hasAttribute("fps")) fps = Integer.valueOf(e.getAttribute("fps"));
updateImage(); updateImage();
} }
...@@ -188,6 +188,7 @@ public class Bitmap extends ImageResource implements ActionListener{ ...@@ -188,6 +188,7 @@ public class Bitmap extends ImageResource implements ActionListener{
} }
return true; return true;
} }
@Override
public void update() { public void update() {
BitmapEditEvent be = new BitmapEditEvent(this); BitmapEditEvent be = new BitmapEditEvent(this);
file=file_tf.getText(); file=file_tf.getText();
...@@ -202,6 +203,7 @@ public class Bitmap extends ImageResource implements ActionListener{ ...@@ -202,6 +203,7 @@ public class Bitmap extends ImageResource implements ActionListener{
be.setNew(); be.setNew();
s.m.hist.addEvent(be); s.m.hist.addEvent(be);
} }
@Override
public void showOptions() { public void showOptions() {
if(frame==null) { if(frame==null) {
frame = new JFrame(Language.get("WIN_BITMAP_TITLE")); frame = new JFrame(Language.get("WIN_BITMAP_TITLE"));
...@@ -366,6 +368,7 @@ public class Bitmap extends ImageResource implements ActionListener{ ...@@ -366,6 +368,7 @@ public class Bitmap extends ImageResource implements ActionListener{
frame.setVisible(true); frame.setVisible(true);
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(file_btn)) { if (e.getSource().equals(file_btn)) {
if(fc==null) { if(fc==null) {
...@@ -431,6 +434,7 @@ public class Bitmap extends ImageResource implements ActionListener{ ...@@ -431,6 +434,7 @@ public class Bitmap extends ImageResource implements ActionListener{
frame = null; frame = null;
} }
} }
@Override
public String returnCode(String indent) { public String returnCode(String indent) {
String code = indent+"<Bitmap id=\""+id+"\" file=\""+file+"\""; String code = indent+"<Bitmap id=\""+id+"\" file=\""+file+"\"";
code+=" alphacolor=\""+alphacolor+"\""; code+=" alphacolor=\""+alphacolor+"\"";
...@@ -448,6 +452,7 @@ public class Bitmap extends ImageResource implements ActionListener{ ...@@ -448,6 +452,7 @@ public class Bitmap extends ImageResource implements ActionListener{
} }
return code; return code;
} }
@Override
public DefaultMutableTreeNode getTreeNode() { public DefaultMutableTreeNode getTreeNode() {
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Bitmap: "+id); DefaultMutableTreeNode node = new DefaultMutableTreeNode("Bitmap: "+id);
for(int i=0;i<SubBitmaps.size();i++) { for(int i=0;i<SubBitmaps.size();i++) {
......
...@@ -119,28 +119,28 @@ public class Font extends Resource implements ActionListener{ ...@@ -119,28 +119,28 @@ public class Font extends Resource implements ActionListener{
} }
public boolean updateFont() { public boolean updateFont() {
try { try {
f = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT,new File(s.skinfolder+file)); f = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT,new File(s.skinfolder+file));
f = f.deriveFont((float)size); f = f.deriveFont((float)size);
} }
catch(Exception e) { catch(Exception e) {
e.printStackTrace();
if(file.indexOf(".otf")==-1) { if(file.indexOf(".otf")==-1) {
//JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE); //Font file corrupt
f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size);
//showOptions();
return false; return false;
} }
else { else {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_OTF_MSG"),Language.get("ERROR_OTF_TITLE"),JOptionPane.INFORMATION_MESSAGE); try {
try { f = java.awt.Font.createFont(java.awt.Font.TYPE1_FONT,new File(s.skinfolder+file));
f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); f = f.deriveFont((float)size);
f = f.deriveFont(12);
} }
catch(Exception ex) { catch(Exception ex) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_OTF_MSG"),Language.get("ERROR_OTF_TITLE"),JOptionPane.INFORMATION_MESSAGE);
ex.printStackTrace(); ex.printStackTrace();
f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size);
} }
return true; return true;
} }
} }
return true; return true;
} }
...@@ -296,6 +296,10 @@ public class Font extends Resource implements ActionListener{ ...@@ -296,6 +296,10 @@ public class Font extends Resource implements ActionListener{
JOptionPane.showMessageDialog(frame,Language.get("ERROR_FILE_INVALID_MSG"),Language.get("ERROR_FILE_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame,Language.get("ERROR_FILE_INVALID_MSG"),Language.get("ERROR_FILE_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
if(size_tf.getText().length()<1) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_SIZE_INVALID_MSG"),Language.get("ERROR_SIZE_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
update(); update();
if(!updateFont()) JOptionPane.showMessageDialog(frame,Language.get("ERROR_FILE_INVALID_MSG"),Language.get("ERROR_FILE_INVALID_TITLE"),JOptionPane.ERROR_MESSAGE); if(!updateFont()) JOptionPane.showMessageDialog(frame,Language.get("ERROR_FILE_INVALID_MSG"),Language.get("ERROR_FILE_INVALID_TITLE"),JOptionPane.ERROR_MESSAGE);
else { else {
......
...@@ -112,7 +112,8 @@ public class SubBitmap extends ImageResource implements ActionListener{ ...@@ -112,7 +112,8 @@ public class SubBitmap extends ImageResource implements ActionListener{
*/ */
public void updateImage() { public void updateImage() {
if(parent.image != null) image = parent.image.getSubimage(x,y,width,height); if(parent.image != null) image = parent.image.getSubimage(x,y,width,height);
} }
@Override
public void update() { public void update() {
if(!created) { if(!created) {
id=id_tf.getText(); id=id_tf.getText();
...@@ -144,42 +145,43 @@ public class SubBitmap extends ImageResource implements ActionListener{ ...@@ -144,42 +145,43 @@ public class SubBitmap extends ImageResource implements ActionListener{
s.expandResource(id); s.expandResource(id);
} }
} }
@Override
public void showOptions() { public void showOptions() {
if(frame==null) { if(frame==null) {
frame = new JFrame("Subbitmap settings"); frame = new JFrame(Language.get("WIN_SBMP_TITLE"));
frame.setResizable(false); frame.setResizable(false);
frame.setLayout(new FlowLayout()); frame.setLayout(new FlowLayout());
if(!created) frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); if(!created) frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
JLabel id_l = new JLabel("ID*:"); JLabel id_l = new JLabel(Language.get("WIN_ITEM_ID"));
id_tf = new JTextField(); id_tf = new JTextField();
id_tf.setToolTipText("Identifiant of the font that will be used with controls.."); id_tf.setToolTipText(Language.get("WIN_ITEM_ID_TIP").replaceAll("%t",type));
JLabel x_l = new JLabel("X:"); JLabel x_l = new JLabel(Language.get("WIN_ITEM_X"));
x_tf = new JTextField(); x_tf = new JTextField();
x_tf.setDocument(new NumbersOnlyDocument(false)); x_tf.setDocument(new NumbersOnlyDocument(false));
JLabel y_l = new JLabel("Y:"); JLabel y_l = new JLabel(Language.get("WIN_ITEM_Y"));
y_tf = new JTextField(); y_tf = new JTextField();
y_tf.setDocument(new NumbersOnlyDocument(false)); y_tf.setDocument(new NumbersOnlyDocument(false));
JLabel width_l = new JLabel("Width:"); JLabel width_l = new JLabel(Language.get("WIN_ITEM_WIDTH"));
width_tf = new JTextField(); width_tf = new JTextField();
width_tf.setDocument(new NumbersOnlyDocument(false)); width_tf.setDocument(new NumbersOnlyDocument(false));
JLabel height_l = new JLabel("Height:"); JLabel height_l = new JLabel(Language.get("WIN_ITEM_HEIGHT"));
height_tf = new JTextField(); height_tf = new JTextField();
height_tf.setDocument(new NumbersOnlyDocument(false)); height_tf.setDocument(new NumbersOnlyDocument(false));
JLabel nbframes_l = new JLabel("Number of frames:"); JLabel nbframes_l = new JLabel(Language.get("WIN_BITMAP_NBFRAMES"));
nbframes_tf = new JTextField(); nbframes_tf = new JTextField();
nbframes_tf.setDocument(new NumbersOnlyDocument(false)); nbframes_tf.setDocument(new NumbersOnlyDocument(false));
nbframes_tf.setToolTipText("This attribute is needed to define animated bitmaps; it is the number of frames (images) contained in your animation. All the different frames are just images laid vertically in the bitmap."); nbframes_tf.setToolTipText(Language.get("WIN_BITMAP_NBFRAMES_TIP"));
JLabel fps_l = new JLabel("Frames per second:"); JLabel fps_l = new JLabel(Language.get("WIN_BITMAP_FPS"));
fps_tf = new JTextField(); fps_tf = new JTextField();
fps_tf.setDocument(new NumbersOnlyDocument(false)); fps_tf.setDocument(new NumbersOnlyDocument(false));
fps_tf.setToolTipText("Only used in animated bitmaps; it is the number of frames (images) per seconds of the animation."); fps_tf.setToolTipText(Language.get("WIN_BITMAP_FPS_TIP"));
ok_btn = new JButton("OK"); ok_btn = new JButton(Language.get("BUTTON_OK"));
ok_btn.addActionListener(this); ok_btn.addActionListener(this);
cancel_btn = new JButton("Cancel"); cancel_btn = new JButton(Language.get("BUTTON_CANCEL"));
cancel_btn.addActionListener(this); cancel_btn.addActionListener(this);
help_btn = new JButton("Help"); help_btn = new JButton(Language.get("BUTTON_HELP"));
help_btn.addActionListener(this); help_btn.addActionListener(this);
JLabel attr_l = new JLabel("* Attributes marked with a star must be specified."); JLabel attr_l = new JLabel(Language.get("NOTE_STARRED"));
//Distance of textfields to WEST edge of container //Distance of textfields to WEST edge of container
Component[] labels = { id_l, x_l, y_l, width_l, height_l, nbframes_l, fps_l}; Component[] labels = { id_l, x_l, y_l, width_l, height_l, nbframes_l, fps_l};
...@@ -191,7 +193,7 @@ public class SubBitmap extends ImageResource implements ActionListener{ ...@@ -191,7 +193,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
general.add(id_l); general.add(id_l);
general.add(id_tf); general.add(id_tf);
id_tf.setPreferredSize(new Dimension(tf_wd,id_tf.getPreferredSize().height)); id_tf.setPreferredSize(new Dimension(tf_wd,id_tf.getPreferredSize().height));
general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes")); general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), Language.get("WIN_ITEM_GENERAL")));
SpringLayout general_layout = new SpringLayout(); SpringLayout general_layout = new SpringLayout();
general.setLayout(general_layout); general.setLayout(general_layout);
general_layout.putConstraint(SpringLayout.NORTH, id_l, 5, SpringLayout.NORTH, general); general_layout.putConstraint(SpringLayout.NORTH, id_l, 5, SpringLayout.NORTH, general);
...@@ -215,7 +217,7 @@ public class SubBitmap extends ImageResource implements ActionListener{ ...@@ -215,7 +217,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
bounds.add(height_l); bounds.add(height_l);
bounds.add(height_tf); bounds.add(height_tf);
height_tf.setPreferredSize(new Dimension(tf_wd,height_tf.getPreferredSize().height)); height_tf.setPreferredSize(new Dimension(tf_wd,height_tf.getPreferredSize().height));
bounds.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Position and Dimension Attributes")); bounds.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), Language.get("WIN_SBMP_BOUNDS")));
SpringLayout bounds_layout = new SpringLayout(); SpringLayout bounds_layout = new SpringLayout();
bounds.setLayout(bounds_layout); bounds.setLayout(bounds_layout);
bounds_layout.putConstraint(SpringLayout.NORTH, x_l, 5, SpringLayout.NORTH, bounds); bounds_layout.putConstraint(SpringLayout.NORTH, x_l, 5, SpringLayout.NORTH, bounds);
...@@ -254,7 +256,7 @@ public class SubBitmap extends ImageResource implements ActionListener{ ...@@ -254,7 +256,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
animation.add(nbframes_tf); animation.add(nbframes_tf);
animation.add(fps_l); animation.add(fps_l);
animation.add(fps_tf); animation.add(fps_tf);
animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes")); animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), Language.get("WIN_BITMAP_ANIMATION")));
SpringLayout ani_layout = new SpringLayout(); SpringLayout ani_layout = new SpringLayout();
animation.setLayout(ani_layout); animation.setLayout(ani_layout);
nbframes_tf.setPreferredSize(new Dimension(tf_wd,nbframes_tf.getPreferredSize().height)); nbframes_tf.setPreferredSize(new Dimension(tf_wd,nbframes_tf.getPreferredSize().height));
...@@ -327,32 +329,33 @@ public class SubBitmap extends ImageResource implements ActionListener{ ...@@ -327,32 +329,33 @@ public class SubBitmap extends ImageResource implements ActionListener{
height_tf.addKeyListener(sbew); height_tf.addKeyListener(sbew);
frame.addWindowListener(sbew); frame.addWindowListener(sbew);
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(ok_btn)) { if(e.getSource().equals(ok_btn)) {
if(id_tf.getText().equals("")) { if(id_tf.getText().equals("")) {
JOptionPane.showMessageDialog(frame,"Please enter a valid ID!","ID not valid",JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame,Language.get("ERROR_ID_INVALID_MSG"),Language.get("ERROR_ID_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
else if(!id_tf.getText().equals(id)) { else if(!id_tf.getText().equals(id)) {
if(s.idExists(id_tf.getText())) { if(s.idExists(id_tf.getText())) {
JOptionPane.showMessageDialog(frame,"The ID \""+id_tf.getText()+"\" already exists, please choose another one.","ID not valid",JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame,Language.get("ERROR_ID_EXISTS_MSG").replaceAll("%i", id_tf.getText()),Language.get("ERROR_ID_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
} }
if(Integer.parseInt(height_tf.getText())<1) { if(width_tf.getText().length()<1 || Integer.parseInt(width_tf.getText())<1) {
JOptionPane.showMessageDialog(frame,"height must be greater 0!","height not valid",JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame,Language.get("ERROR_WIDTH_INVALID_MSG"),Language.get("ERROR_WIDTH_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
if(Integer.parseInt(height_tf.getText())<1) { if(height_tf.getText().length()<1 || Integer.parseInt(height_tf.getText())<1) {
JOptionPane.showMessageDialog(frame,"Height must be greater 0!","Height not valid",JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame,Language.get("ERROR_HEIGHT_INVALID_MSG"),Language.get("ERROR_HEIGHT_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
if(Integer.parseInt(x_tf.getText())+Integer.parseInt(width_tf.getText())>parent.image.getWidth()) { if(Integer.parseInt(x_tf.getText())+Integer.parseInt(width_tf.getText())>parent.image.getWidth()) {
JOptionPane.showMessageDialog(frame,"Specified dimensions are outside the parent bitmap!","Dimension not valid",JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame,Language.get("ERROR_OUTSIDE_MSG"),Language.get("ERROR_OUTSIDE_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
if(Integer.parseInt(y_tf.getText())+Integer.parseInt(height_tf.getText())>parent.image.getHeight()) { if(Integer.parseInt(y_tf.getText())+Integer.parseInt(height_tf.getText())>parent.image.getHeight()) {
JOptionPane.showMessageDialog(frame,"Specified dimensions are outside the parent bitmap!","Dimension not valid",JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame,Language.get("ERROR_OUTSIDE_MSG"),Language.get("ERROR_OUTSIDE_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
update(); update();
...@@ -383,6 +386,7 @@ public class SubBitmap extends ImageResource implements ActionListener{ ...@@ -383,6 +386,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
sbew.frame = null; sbew.frame = null;
sbew = null; sbew = null;
} }
@Override
public String returnCode(String indent) { public String returnCode(String indent) {
String code=indent+"<SubBitmap id=\""+id+"\" x=\""+String.valueOf(x)+"\" y=\""+String.valueOf(y)+"\""; String code=indent+"<SubBitmap id=\""+id+"\" x=\""+String.valueOf(x)+"\" y=\""+String.valueOf(y)+"\"";
code+=" height=\""+String.valueOf(height)+"\" width=\""+String.valueOf(width)+"\""; code+=" height=\""+String.valueOf(height)+"\" width=\""+String.valueOf(width)+"\"";
...@@ -391,6 +395,7 @@ public class SubBitmap extends ImageResource implements ActionListener{ ...@@ -391,6 +395,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
code+="/>\n"; code+="/>\n";
return code; return code;
} }
@Override
public DefaultMutableTreeNode getTreeNode() { public DefaultMutableTreeNode getTreeNode() {
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Bitmap: "+id); DefaultMutableTreeNode top = new DefaultMutableTreeNode("Bitmap: "+id);
return top; return top;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment