Changeset 90
- Timestamp:
- 29/12/07 14:28:21 (1 year ago)
- Files:
-
- trunk/README.TXT (modified) (1 diff)
- trunk/src/vlcskineditor/resources/SubBitmapEditWindow.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/README.TXT
r88 r90 4 4 ----------------------------------------------------------- 5 5 0.7.0a - Preview can be saved as image 6 - Improved SubBitmap editing 6 7 0.6.1b - Critical bufix for the Preview Window 7 8 - Bugfix for slider points parsing and XML parsing trunk/src/vlcskineditor/resources/SubBitmapEditWindow.java
r87 r90 32 32 * @author Daniel Dreibrodt 33 33 */ 34 public class SubBitmapEditWindow extends JPanel implements MouseListener, MouseMotionListener, KeyListener, WindowListener{34 public class SubBitmapEditWindow extends JPanel implements ActionListener, MouseListener, MouseMotionListener, KeyListener, WindowListener{ 35 35 36 36 public JFrame frame; 37 JScrollPane scroll_pane; 38 JPanel zoom_panel; 39 JButton zoom_more, zoom_less; 40 JLabel zoom_label; 41 int z_fact = 1; 37 42 Bitmap b; 38 43 SubBitmap sb; … … 42 47 int x1, y1, x2, y2; 43 48 int x1_org, y1_org, x2_org, y2_org; 44 int maxx, maxy;49 int p_width, p_height; 45 50 int drawcount; 46 51 … … 55 60 y2_org = y2 = sb.y+sb.height; 56 61 frame = new JFrame("Edit SubBitmap"); 57 frame.setLayout(new GridLayout(1,1)); 58 frame.add(this); 59 maxx = b.image.getWidth(); 60 maxy = b.image.getHeight(); 61 setMinimumSize(new Dimension(maxx,maxy)); 62 setPreferredSize(new Dimension(maxx,maxy)); 62 frame.setLayout(new BorderLayout()); 63 zoom_panel = new JPanel(); 64 zoom_panel.setLayout(new FlowLayout()); 65 zoom_less = new JButton("-"); 66 zoom_less.addActionListener(this); 67 zoom_panel.add(zoom_less); 68 zoom_label = new JLabel("Zoom factor: 1x"); 69 zoom_panel.add(zoom_label); 70 zoom_more = new JButton("+"); 71 zoom_more.addActionListener(this); 72 zoom_panel.add(zoom_more); 73 zoom_panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); 74 frame.add(zoom_panel, BorderLayout.PAGE_START); 75 p_width = b.image.getWidth(); 76 p_height = b.image.getHeight(); 77 setPreferredSize(new Dimension(p_width,p_height)); 78 scroll_pane = new JScrollPane(this); 79 scroll_pane.setPreferredSize(new Dimension(p_width+20,p_height+20)); 80 frame.add(scroll_pane,BorderLayout.CENTER); 63 81 frame.pack(); 64 82 frame.setLocation(sb.frame.getX()+sb.frame.getWidth()+5,sb.frame.getY()); 65 frame.set Resizable(false);83 frame.setMinimumSize(new Dimension(200,100)); 66 84 frame.setVisible(true); 67 85 fu = new FrameUpdater(this,25); … … 75 93 if(drawcount>=40) drawcount = 0; 76 94 g.clearRect(0,0,getWidth(),getHeight()); 77 g.drawImage(b.image,0,0,frame); 95 g.drawImage(b.image, 0, 0, p_width*z_fact, p_height*z_fact, frame); 96 //g.drawImage(b.image,0,0,frame); 78 97 g.setColor(Color.RED); 79 98 int[] x = new int[4]; 80 x[0] = x1 ;81 x[1] = x2 ;82 x[2] = x2 ;83 x[3] = x1 ;99 x[0] = x1*z_fact; 100 x[1] = x2*z_fact; 101 x[2] = x2*z_fact; 102 x[3] = x1*z_fact; 84 103 int[] y = new int[4]; 85 y[0] = y1 ;86 y[1] = y1 ;87 y[2] = y2 ;88 y[3] = y2 ;104 y[0] = y1*z_fact; 105 y[1] = y1*z_fact; 106 y[2] = y2*z_fact; 107 y[3] = y2*z_fact; 89 108 if(drawcount<=20 || starteddragging) 90 109 g.drawPolygon(x,y,4); … … 103 122 x2_org = x2; 104 123 y2_org = y2; 105 x2 = x1 = e.getX() ;106 y2 = y1 = e.getY() ;124 x2 = x1 = e.getX()/z_fact; 125 y2 = y1 = e.getY()/z_fact; 107 126 } 108 127 else { 109 if(e.getX() >=maxx) x2=maxx;110 else if(e.getX() <0) x2=0;111 else x2 = e.getX() ;112 if(e.getY() >=maxy) y2=maxy;113 else if(e.getY() <0) y2=0;114 else y2 = e.getY() ;128 if(e.getX()/z_fact>=p_width) x2=p_width; 129 else if(e.getX()/z_fact<0) x2=0; 130 else x2 = e.getX()/z_fact; 131 if(e.getY()/z_fact>=p_height) y2=p_height; 132 else if(e.getY()/z_fact<0) y2=0; 133 else y2 = e.getY()/z_fact; 115 134 } 116 135 } … … 182 201 public void windowDeactivated(WindowEvent e) { 183 202 } 203 public void actionPerformed(ActionEvent e) { 204 if(e.getSource().equals(zoom_less)) { 205 if(z_fact>1) z_fact--; 206 zoom_label.setText("Zoom factor: "+z_fact+"x"); 207 setSize(p_width*z_fact, p_height*z_fact); 208 setPreferredSize(new Dimension(p_width*z_fact, p_height*z_fact)); 209 } 210 else if(e.getSource().equals(zoom_more)) { 211 if(z_fact<16) z_fact++; 212 zoom_label.setText("Zoom factor: "+z_fact+"x"); 213 setSize(p_width*z_fact, p_height*z_fact); 214 setPreferredSize(new Dimension(p_width*z_fact, p_height*z_fact)); 215 } 216 } 184 217 }
