Skip to content

Commit

Permalink
DemoApplication
Browse files Browse the repository at this point in the history
- AbstractTitledPreview.java - Separated from `AbstractStylePreview` for convenience
- ImageGroup.java, SvgGroup.java, SvgIconExample.java - Added `SvgIcon` usage examples
- firefox.svg, mona.svg - Sample SVG icons
  • Loading branch information
mgarin committed Dec 11, 2017
1 parent b07639c commit a9d5aec
Show file tree
Hide file tree
Showing 12 changed files with 906 additions and 148 deletions.
150 changes: 2 additions & 148 deletions modules/demo/src/com/alee/demo/api/example/AbstractStylePreview.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,23 @@

package com.alee.demo.api.example;

import com.alee.demo.skin.DemoStyles;
import com.alee.extended.label.WebStyledLabel;
import com.alee.extended.layout.HorizontalFlowLayout;
import com.alee.laf.panel.WebPanel;
import com.alee.laf.separator.WebSeparator;
import com.alee.managers.style.Skin;
import com.alee.managers.style.StyleId;
import com.alee.managers.style.StyleManager;
import com.alee.utils.SwingUtils;

import javax.swing.*;
import java.awt.*;
import java.util.List;

/**
* Each {@link AbstractStylePreview} is tied to specific skin style.
*
* @author Mikle Garin
*/

public abstract class AbstractStylePreview extends AbstractPreview
public abstract class AbstractStylePreview extends AbstractTitledPreview
{
/**
* Preview style ID.
*/
protected final StyleId styleId;

/**
* Preview container.
*/
protected PreviewPanel previewPanel;

/**
* Preview information.
*/
protected JComponent previewInfo;

/**
* Preview content elements.
*/
protected List<? extends JComponent> previewContent;

/**
* Constructs new style preview.
* Constructs new {@link AbstractStylePreview}.
*
* @param example example this preview belongs to
* @param id preview ID
Expand All @@ -82,123 +55,4 @@ protected StyleId getStyleId ()
{
return styleId;
}

@Override
protected JComponent createPreview ( final List<Preview> previews, final int index )
{
final Preview preview = previews.get ( index );

final HorizontalFlowLayout layout = new HorizontalFlowLayout ( 0, true );
previewPanel = new PreviewPanel ( preview.getFeatureState (), layout );
previewPanel.add ( getPreviewInfo () );
previewPanel.add ( createSeparator () );
previewPanel.add ( createPreviewContent () );
return previewPanel;
}

@Override
public JComponent getEqualizableWidthComponent ()
{
return getPreviewInfo ();
}

/**
* Returns cached preview component information.
*
* @return cached preview component information
*/
protected JComponent getPreviewInfo ()
{
if ( previewInfo == null )
{
previewInfo = createPreviewInfo ();
}
return previewInfo;
}

/**
* Returns preview component information.
*
* @return preview component information
*/
protected JComponent createPreviewInfo ()
{
final StyleId styleId = DemoStyles.previewTitleLabel.at ( previewPanel );
return new WebStyledLabel ( styleId, getTitle () ).setBoldFont ();
}

/**
* Returns newly created information and content separator.
*
* @return newly created information and content separator
*/
protected WebSeparator createSeparator ()
{
final StyleId styleId = DemoStyles.previewSeparator.at ( previewPanel );
return new WebSeparator ( styleId );
}

/**
* Returns newly created previewed elements container.
*
* @return newly created previewed elements container
*/
protected JComponent createPreviewContent ()
{
final StyleId styleId = DemoStyles.previewContent.at ( previewPanel );
final WebPanel contentPanel = new WebPanel ( styleId, createPreviewLayout () );
contentPanel.add ( getPreviewElements () );
return contentPanel;
}

/**
* Returns newly created previewed elements container layout.
*
* @return newly created previewed elements container layout
*/
protected LayoutManager createPreviewLayout ()
{
return new HorizontalFlowLayout ( 8, false );
}

/**
* Returns cached preview content elements.
* This can be anything provided by the specific preview.
*
* @return cached preview content elements
*/
protected List<? extends JComponent> getPreviewElements ()
{
if ( previewContent == null )
{
previewContent = createPreviewElements ();
}
return previewContent;
}

/**
* Returns preview content component.
* This can be anything provided by the example.
*
* @return preview content component
*/
protected abstract List<? extends JComponent> createPreviewElements ();

@Override
public void applySkin ( final Skin skin )
{
for ( final JComponent component : getPreviewElements () )
{
StyleManager.setSkin ( component, skin, true );
}
}

@Override
public void applyEnabled ( final boolean enabled )
{
for ( final JComponent component : getPreviewElements () )
{
SwingUtils.setEnabledRecursively ( component, enabled );
}
}
}
187 changes: 187 additions & 0 deletions modules/demo/src/com/alee/demo/api/example/AbstractTitledPreview.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library 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 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library 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 WebLookAndFeel library. If not, see <http://www.gnu.org/licenses/>.
*/

package com.alee.demo.api.example;

import com.alee.demo.skin.DemoStyles;
import com.alee.extended.label.WebStyledLabel;
import com.alee.extended.layout.HorizontalFlowLayout;
import com.alee.laf.panel.WebPanel;
import com.alee.laf.separator.WebSeparator;
import com.alee.managers.style.Skin;
import com.alee.managers.style.StyleId;
import com.alee.managers.style.StyleManager;
import com.alee.utils.SwingUtils;

import javax.swing.*;
import java.awt.*;
import java.util.List;

/**
* Each {@link AbstractTitledPreview} has a custom title.
*
* @author Mikle Garin
*/

public abstract class AbstractTitledPreview extends AbstractPreview
{
/**
* Preview container.
*/
protected PreviewPanel previewPanel;

/**
* Preview information.
*/
protected JComponent previewInfo;

/**
* Preview content elements.
*/
protected List<? extends JComponent> previewContent;

/**
* Constructs new {@link AbstractTitledPreview}.
*
* @param example example this preview belongs to
* @param id preview ID
* @param state feature state
*/
public AbstractTitledPreview ( final Example example, final String id, final FeatureState state )
{
super ( example, id, state );
}

@Override
protected JComponent createPreview ( final List<Preview> previews, final int index )
{
final Preview preview = previews.get ( index );

final HorizontalFlowLayout layout = new HorizontalFlowLayout ( 0, true );
previewPanel = new PreviewPanel ( preview.getFeatureState (), layout );
previewPanel.add ( getPreviewInfo () );
previewPanel.add ( createSeparator () );
previewPanel.add ( createPreviewContent () );
return previewPanel;
}

@Override
public JComponent getEqualizableWidthComponent ()
{
return getPreviewInfo ();
}

/**
* Returns cached preview component information.
*
* @return cached preview component information
*/
protected JComponent getPreviewInfo ()
{
if ( previewInfo == null )
{
previewInfo = createPreviewInfo ();
}
return previewInfo;
}

/**
* Returns preview component information.
*
* @return preview component information
*/
protected JComponent createPreviewInfo ()
{
final StyleId styleId = DemoStyles.previewTitleLabel.at ( previewPanel );
return new WebStyledLabel ( styleId, getTitle () ).setBoldFont ();
}

/**
* Returns newly created information and content separator.
*
* @return newly created information and content separator
*/
protected WebSeparator createSeparator ()
{
final StyleId styleId = DemoStyles.previewSeparator.at ( previewPanel );
return new WebSeparator ( styleId );
}

/**
* Returns newly created previewed elements container.
*
* @return newly created previewed elements container
*/
protected JComponent createPreviewContent ()
{
final StyleId styleId = DemoStyles.previewContent.at ( previewPanel );
final WebPanel contentPanel = new WebPanel ( styleId, createPreviewLayout () );
contentPanel.add ( getPreviewElements () );
return contentPanel;
}

/**
* Returns newly created previewed elements container layout.
*
* @return newly created previewed elements container layout
*/
protected LayoutManager createPreviewLayout ()
{
return new HorizontalFlowLayout ( 8, false );
}

/**
* Returns cached preview content elements.
* This can be anything provided by the specific preview.
*
* @return cached preview content elements
*/
protected List<? extends JComponent> getPreviewElements ()
{
if ( previewContent == null )
{
previewContent = createPreviewElements ();
}
return previewContent;
}

/**
* Returns preview content component.
* This can be anything provided by the example.
*
* @return preview content component
*/
protected abstract List<? extends JComponent> createPreviewElements ();

@Override
public void applySkin ( final Skin skin )
{
for ( final JComponent component : getPreviewElements () )
{
StyleManager.setSkin ( component, skin, true );
}
}

@Override
public void applyEnabled ( final boolean enabled )
{
for ( final JComponent component : getPreviewElements () )
{
SwingUtils.setEnabledRecursively ( component, enabled );
}
}
}
2 changes: 2 additions & 0 deletions modules/demo/src/com/alee/demo/content/ExamplesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.alee.demo.content.container.ContainersGroup;
import com.alee.demo.content.data.DataGroup;
import com.alee.demo.content.desktoppane.DesktopPaneGroup;
import com.alee.demo.content.image.ImageGroup;
import com.alee.demo.content.label.LabelsGroup;
import com.alee.demo.content.menu.MenusGroup;
import com.alee.demo.content.progress.ProgressGroup;
Expand Down Expand Up @@ -91,6 +92,7 @@ public static synchronized void initialize ()
groups.add ( new ChoosersGroup () );
groups.add ( new WindowsGroup () );
groups.add ( new DesktopPaneGroup () );
groups.add ( new ImageGroup () );
groups.add ( new AnimationGroup () );
}
}
Expand Down
Loading

0 comments on commit a9d5aec

Please sign in to comment.