Skip to content

Commit

Permalink
#77 - All suggested changes included in this commit
Browse files Browse the repository at this point in the history
#70 - WebRootPaneUI fix for empty title and window drag
#36 - More fixes for Swing borders honor option
WebRootPaneUI fix for resizable window property changes
Empty title and max title width added into WebRootPaneUI style settings
WebImageDrop JavaDoc and small improvements added
Disabled icons caching added to improve performance
ReflectUtils type check for null arguments fix
WebComboBoxUI wheel scrolling through choices fix
Additional "show" methods for WebPopOver
Background color can now be easily set for WebPopOver
WebSplitButtonUI creation fix
WebToolBarUI incorrect buttons border updates fix
FormLayout improvements
Small readme updates
  • Loading branch information
mgarin committed Jan 24, 2014
1 parent 327205a commit b1af35b
Show file tree
Hide file tree
Showing 54 changed files with 1,560 additions and 469 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ WebLaF
**WebLaf** is a Java Swing Look and Feel and extended components library for cross-platform applications.<br>
![Preview](http://s5.hostingkartinok.com/uploads/images/2013/10/92f65b6b3262493a5f386dc6808efbba.png)

Main advantages
Advantages
----------

- Simple and stylish cross-platform default theme
Expand Down
11 changes: 6 additions & 5 deletions src/com/alee/examples/content/IconProgress.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,27 @@ public class IconProgress extends WebPanel
public IconProgress ()
{
super ( true, new HorizontalFlowLayout ( 2, false ) );
setOpaque ( false );
setMargin ( 2 );
setWebColored ( false );
setBackground ( Color.WHITE );
}

public void addLoadedElement ( Icon icon )
public void addLoadedElement ( final Icon icon )
{
add ( new FadeInImage ( ImageUtils.getBufferedImage ( icon ) ) );
}

private class FadeInImage extends WebImage
{
public FadeInImage ( Image image )
public FadeInImage ( final Image image )
{
super ( image );
setTransparency ( 0f );
addAncestorListener ( new AncestorAdapter ()
{
@Override
public void ancestorAdded ( AncestorEvent event )
public void ancestorAdded ( final AncestorEvent event )
{
fadeIn ();
}
Expand All @@ -71,9 +72,9 @@ private void fadeIn ()
WebTimer.repeat ( "FadeInImage.updater", StyleConstants.avgAnimationDelay, new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
public void actionPerformed ( final ActionEvent e )
{
float t = getTransparency ();
final float t = getTransparency ();
if ( t < 1f )
{
setTransparency ( Math.min ( t + 0.05f, 1f ) );
Expand Down
4 changes: 2 additions & 2 deletions src/com/alee/extended/button/WebSplitButtonUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public class WebSplitButtonUI extends WebButtonUI
* @param c component that will use UI instance
* @return instance of the WebSplitButtonUI
*/
@SuppressWarnings ( "UnusedParameters" )
@SuppressWarnings ("UnusedParameters")
public static ComponentUI createUI ( final JComponent c )
{
return new WebButtonUI ();
return new WebSplitButtonUI ();
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/com/alee/extended/button/WebSwitchGripper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class WebSwitchGripper extends WebPanel
public WebSwitchGripper ()
{
super ( true );
setOpaque ( false );
setRound ( WebSwitchStyle.gripperRound );
}
}
144 changes: 118 additions & 26 deletions src/com/alee/extended/image/WebImageDrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,67 @@
import java.util.List;

/**
* User: mgarin Date: 11/14/11 Time: 4:34 PM
* This is a custom image drop component.
* It serves as a drop area for images and will display dropped image preview.
* You can always retrieve actual and thumbnail images from this components if there are any.
*
* @author Mikle Garin
*/

public class WebImageDrop extends JComponent
{
private int round;
private int width;
private int height;
private BufferedImage actualImage;
private BufferedImage image;

/**
* Preview image corners rounding.
*/
protected int round;

/**
* Preview image area width.
*/
protected int width;

/**
* Preview image area height.
*/
protected int height;

/**
* Actual image placed into WebImageDrop component.
*/
protected BufferedImage actualImage;

/**
* Preview image.
*/
protected BufferedImage image;

/**
* Constructs new WebImageDrop component with 64x64 preview image area size.
*/
public WebImageDrop ()
{
this ( 64, 64 );
}

public WebImageDrop ( int width, int height )
/**
* Constructs new WebImageDrop component with the specified preview image area size.
*
* @param width preview image area width
* @param height preview image area height
*/
public WebImageDrop ( final int width, final int height )
{
this ( width, height, null );
}

public WebImageDrop ( int width, int height, BufferedImage image )
/**
* Constructs new WebImageDrop component with the specified preview image area size and actual image.
*
* @param width preview image area width
* @param height preview image area height
* @param image actual image
*/
public WebImageDrop ( final int width, final int height, final BufferedImage image )
{
super ();

Expand All @@ -70,13 +109,13 @@ public WebImageDrop ( int width, int height, BufferedImage image )
setTransferHandler ( new ImageDropHandler ()
{
@Override
protected boolean imagesImported ( List<ImageIcon> images )
protected boolean imagesImported ( final List<ImageIcon> images )
{
for ( ImageIcon image : images )
for ( final ImageIcon image : images )
{
try
{
setImage ( ImageUtils.getBufferedImage ( images.get ( 0 ) ) );
setImage ( ImageUtils.getBufferedImage ( image ) );
return true;
}
catch ( Throwable e )
Expand All @@ -89,69 +128,116 @@ protected boolean imagesImported ( List<ImageIcon> images )
} );
}

/**
* Returns actual image.
*
* @return actual image
*/
public BufferedImage getImage ()
{
return actualImage;
}

/**
* Returns preview image.
*
* @return preview image
*/
public BufferedImage getThumbnail ()
{
return image;
}

/**
* Returns preview image corners rounding.
*
* @return preview image corners rounding
*/
public int getRound ()
{
return round;
}

public void setRound ( int round )
/**
* Sets preview image corners rounding.
*
* @param round new preview image corners rounding
*/
public void setRound ( final int round )
{
this.round = round;
updatePreview ();
}

/**
* Returns preview image area width.
*
* @return preview image area width
*/
public int getImageWidth ()
{
return width;
}

public void setImageWidth ( int width )
/**
* Sets preview image area width.
*
* @param width preview image area width
*/
public void setImageWidth ( final int width )
{
this.width = width;
updatePreview ();
}

/**
* Returns preview image area height.
*
* @return preview image area height
*/
public int getImageHeight ()
{
return height;
}

public void setImageHeight ( int height )
/**
* Sets preview image area height.
*
* @param height new preview image area height
*/
public void setImageHeight ( final int height )
{
this.height = height;
updatePreview ();
}

public void setImage ( BufferedImage image )
/**
* Sets new displayed image.
* This forces a new preview image to be generated so be aware that this call does some heavy work.
*
* @param image new displayed image
*/
public void setImage ( final BufferedImage image )
{
this.actualImage = image;

this.image = image;
updatePreview ();

repaint ();
}

private void updatePreview ()
/**
* Updates image preview.
*/
protected void updatePreview ()
{
if ( image != null )
{
// Validate size
// Creating image preview
image = ImageUtils.createPreviewImage ( actualImage, width, height );

// Restore decoration
BufferedImage f = ImageUtils.createCompatibleImage ( image, Transparency.TRANSLUCENT );
Graphics2D g2d = f.createGraphics ();
final BufferedImage f = ImageUtils.createCompatibleImage ( image, Transparency.TRANSLUCENT );
final Graphics2D g2d = f.createGraphics ();
LafUtils.setupAntialias ( g2d );
g2d.setPaint ( Color.WHITE );
g2d.fillRoundRect ( 0, 0, image.getWidth (), image.getHeight (), round * 2, round * 2 );
Expand All @@ -164,20 +250,23 @@ private void updatePreview ()
}
}

/**
* {@inheritDoc}
*/
@Override
protected void paintComponent ( Graphics g )
protected void paintComponent ( final Graphics g )
{
super.paintComponent ( g );

Graphics2D g2d = ( Graphics2D ) g;
final Graphics2D g2d = ( Graphics2D ) g;
LafUtils.setupAntialias ( g2d );

if ( image != null )
{
g2d.drawImage ( image, getWidth () / 2 - image.getWidth () / 2 + 1, getHeight () / 2 - image.getHeight () / 2 + 1, null );
}

Shape border = new RoundRectangle2D.Double ( getWidth () / 2 - width / 2 + 1, getHeight () / 2 - height / 2 + 1,
final Shape border = new RoundRectangle2D.Double ( getWidth () / 2 - width / 2 + 1, getHeight () / 2 - height / 2 + 1,
width - ( image == null ? 3 : 1 ), height - ( image == null ? 3 : 1 ), round * 2, round * 2 );

if ( image == null )
Expand All @@ -192,9 +281,12 @@ protected void paintComponent ( Graphics g )
}
}

/**
* {@inheritDoc}
*/
@Override
public Dimension getPreferredSize ()
{
return new Dimension ( width + 2, height + 2 );
}
}
}
Loading

0 comments on commit b1af35b

Please sign in to comment.