diff --git a/component/src/main/java/org/pushingpixels/radiance/component/internal/ui/ribbon/appmenu/BasicRibbonApplicationMenuPopupPanelUI.java b/component/src/main/java/org/pushingpixels/radiance/component/internal/ui/ribbon/appmenu/BasicRibbonApplicationMenuPopupPanelUI.java index 2934d6dac..9808fdaa7 100644 --- a/component/src/main/java/org/pushingpixels/radiance/component/internal/ui/ribbon/appmenu/BasicRibbonApplicationMenuPopupPanelUI.java +++ b/component/src/main/java/org/pushingpixels/radiance/component/internal/ui/ribbon/appmenu/BasicRibbonApplicationMenuPopupPanelUI.java @@ -168,6 +168,9 @@ public void layoutContainer(Container parent) { .setPresentationState(MENU_TILE_LEVEL_1) .setHorizontalAlignment(HorizontalAlignment.FILL) .setPopupPlacementStrategy(RadianceThemingSlices.PopupPlacementStrategy.Endward.VALIGN_TOP) + .setIconFilterStrategies(ribbonAppMenuProjection.getPresentationModel().getItemActiveIconFilterStrategy(), + ribbonAppMenuProjection.getPresentationModel().getItemEnabledIconFilterStrategy(), + ribbonAppMenuProjection.getPresentationModel().getItemDisabledIconFilterStrategy()) .setSelectedStateHighlight(CommandButtonPresentationModel.SelectedStateHighlight.ICON_ONLY) .setPopupFireTrigger(CommandButtonPresentationModel.PopupFireTrigger.ON_ROLLOVER) .build(); @@ -212,6 +215,9 @@ public void layoutContainer(Container parent) { JRibbonApplicationMenuPopupPanelSecondary secondary = JRibbonApplicationMenuPopupPanelSecondary.getPanel(menuEntry, commandOverlays, secondaryMenuPresentationState, + ribbonAppMenuProjection.getPresentationModel().getItemActiveIconFilterStrategy(), + ribbonAppMenuProjection.getPresentationModel().getItemEnabledIconFilterStrategy(), + ribbonAppMenuProjection.getPresentationModel().getItemDisabledIconFilterStrategy(), commandButton); secondary.applyComponentOrientation( applicationMenuPopupPanel.getComponentOrientation()); @@ -277,18 +283,22 @@ public void paint(Graphics g) { if (ribbonAppMenu != null) { final Map commandOverlays = ribbonAppMenuProjection.getCommandOverlays(); + CommandButtonPresentationModel baseFooterCommandPresentation = + CommandButtonPresentationModel.builder() + .setPresentationState(CommandButtonPresentationState.MEDIUM) + .setBackgroundAppearanceStrategy(RadianceThemingSlices.BackgroundAppearanceStrategy.ALWAYS) + .setIconFilterStrategies(ribbonAppMenuProjection.getPresentationModel().getItemActiveIconFilterStrategy(), + ribbonAppMenuProjection.getPresentationModel().getItemEnabledIconFilterStrategy(), + ribbonAppMenuProjection.getPresentationModel().getItemDisabledIconFilterStrategy()) + .build(); for (Command footerCommand : ribbonAppMenu.getFooterCommands().getCommands()) { - CommandButtonPresentationModel commandPresentation = - CommandButtonPresentationModel.builder() - .setPresentationState(CommandButtonPresentationState.MEDIUM) - .setBackgroundAppearanceStrategy(RadianceThemingSlices.BackgroundAppearanceStrategy.ALWAYS) - .build(); + CommandButtonPresentationModel footerCommandPresentation = baseFooterCommandPresentation; if (commandOverlays.containsKey(footerCommand)) { - commandPresentation = commandPresentation.overlayWith( + footerCommandPresentation = baseFooterCommandPresentation.overlayWith( commandOverlays.get(footerCommand)); } JCommandButton commandFooterButton = - footerCommand.project(commandPresentation).buildComponent(); + footerCommand.project(footerCommandPresentation).buildComponent(); this.footerPanel.add(commandFooterButton); } } diff --git a/component/src/main/java/org/pushingpixels/radiance/component/internal/ui/ribbon/appmenu/JRibbonApplicationMenuPopupPanelSecondary.java b/component/src/main/java/org/pushingpixels/radiance/component/internal/ui/ribbon/appmenu/JRibbonApplicationMenuPopupPanelSecondary.java index d1390d915..359761cb8 100644 --- a/component/src/main/java/org/pushingpixels/radiance/component/internal/ui/ribbon/appmenu/JRibbonApplicationMenuPopupPanelSecondary.java +++ b/component/src/main/java/org/pushingpixels/radiance/component/internal/ui/ribbon/appmenu/JRibbonApplicationMenuPopupPanelSecondary.java @@ -50,6 +50,9 @@ public static JRibbonApplicationMenuPopupPanelSecondary getPanel( Command primaryMenuEntry, Map commandOverlays, CommandButtonPresentationState secondaryMenuPresentationState, + RadianceThemingSlices.IconFilterStrategy activeIconFilterStrategy, + RadianceThemingSlices.IconFilterStrategy enabledIconFilterStrategy, + RadianceThemingSlices.IconFilterStrategy disabledIconFilterStrategy, JCommandButton commandButton) { CommandPanelProjection projection = new CommandPanelProjection( new CommandPanelContentModel(primaryMenuEntry.getSecondaryContentModel() @@ -62,6 +65,8 @@ public static JRibbonApplicationMenuPopupPanelSecondary getPanel( RadianceThemingSlices.PopupPlacementStrategy.Endward.VALIGN_TOP) .setCommandPopupFireTrigger(CommandButtonPresentationModel.PopupFireTrigger.ON_ROLLOVER) .setCommandSelectedStateHighlight(CommandButtonPresentationModel.SelectedStateHighlight.ICON_ONLY) + .setIconFilterStrategies(activeIconFilterStrategy, enabledIconFilterStrategy, + disabledIconFilterStrategy) .build()); projection.setCommandOverlays(commandOverlays); diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/ribbon/SmallRibbon.java b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/ribbon/SmallRibbon.java new file mode 100644 index 000000000..5b0483182 --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/ribbon/SmallRibbon.java @@ -0,0 +1,124 @@ +package org.pushingpixels.radiance.demo.component.ribbon; + +import org.pushingpixels.radiance.component.api.common.CommandButtonPresentationState; +import org.pushingpixels.radiance.component.api.common.model.*; +import org.pushingpixels.radiance.component.api.common.model.panel.MenuPopupPanelLayoutSpec; +import org.pushingpixels.radiance.component.api.common.popup.model.CommandPopupMenuPresentationModel; +import org.pushingpixels.radiance.component.api.common.projection.CommandButtonProjection; +import org.pushingpixels.radiance.component.api.common.projection.CommandStripProjection; +import org.pushingpixels.radiance.component.api.ribbon.*; +import org.pushingpixels.radiance.component.api.ribbon.model.RibbonApplicationMenuCommand; +import org.pushingpixels.radiance.component.api.ribbon.projection.RibbonApplicationMenuCommandButtonProjection; +import org.pushingpixels.radiance.component.api.ribbon.resize.CoreRibbonResizePolicies; +import org.pushingpixels.radiance.demo.component.svg.material.transcoded.*; +import org.pushingpixels.radiance.theming.api.RadianceThemingCortex; +import org.pushingpixels.radiance.theming.api.RadianceThemingSlices; +import org.pushingpixels.radiance.theming.api.skin.CeruleanSkin; +import org.pushingpixels.radiance.theming.api.skin.CremeCoffeeSkin; +import org.pushingpixels.radiance.theming.api.skin.TwilightSkin; + +import javax.swing.*; +import java.awt.*; +import java.util.Collections; + +public class SmallRibbon { + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> { + JFrame.setDefaultLookAndFeelDecorated(true); + RadianceThemingCortex.GlobalScope.setSkin(new TwilightSkin()); + + JRibbonFrame frame = new JRibbonFrame("Menu Application Test"); + + Command start = Command.builder().setIconFactory(skip_previous.factory()) + .setText("Start").build(); + Command rwd = Command.builder().setIconFactory(fast_rewind.factory()) + .setText("Rewind").build(); + Command play = Command.builder().setToggle().setIconFactory(play_arrow.factory()) + .setText("Play").build(); + Command fwd = Command.builder().setIconFactory(fast_forward.factory()) + .setText("Forward").build(); + Command end = Command.builder().setIconFactory(skip_next.factory()) + .setText("End").build(); + + CommandGroup commandGroup = new CommandGroup(start, rwd, play, fwd, end); + CommandMenuContentModel popupMenuContentModel = new CommandMenuContentModel(commandGroup); + + + CommandPopupMenuPanelPresentationModel popupMenuPanelPresentationModel = + CommandPopupMenuPanelPresentationModel.builder() + .setIconFilterStrategies( + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT) + .setLayoutSpec(new MenuPopupPanelLayoutSpec(2, 5)) + .setCommandPresentationState(CommandButtonPresentationState.BIG).build(); + CommandPopupMenuPresentationModel popupMenuPresentationModel = + CommandPopupMenuPresentationModel.builder() + .setItemFilterStrategies( + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT) + .setPanelPresentationModel(popupMenuPanelPresentationModel).build(); + + CommandButtonProjection popupProjection = + Command.builder().setText("Popup") + .setIconFactory(play_arrow.factory()) + .setSecondaryContentModel(popupMenuContentModel) + .build().project( + CommandButtonPresentationModel.builder() + .setPresentationState(CommandButtonPresentationState.BIG) + .setIconFilterStrategies( + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT) + .setPopupMenuPresentationModel(popupMenuPresentationModel).build()); + JRibbonBand popupTestBand = new JRibbonBand("Pop", play_arrow.factory()); + popupTestBand.addRibbonCommand(popupProjection, JRibbonBand.PresentationPriority.TOP); + + popupTestBand.setResizePolicies(Collections.singletonList( + new CoreRibbonResizePolicies.Mirror(popupTestBand))); + frame.getRibbon().addTask(new RibbonTask("Popup", popupTestBand)); + + CommandStripProjection stripProjection = + new CommandStripProjection(commandGroup, + CommandStripPresentationModel.builder() + .setIconFilterStrategies( + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.ORIGINAL) + .setHorizontalGapScaleFactor(1.3f) + .setCommandPresentationState(CommandButtonPresentationState.SMALL) + .build()); + JFlowRibbonBand flowRibbonBand = new JFlowRibbonBand("Commands", play_arrow.factory()); + flowRibbonBand.addFlowComponent(stripProjection); + frame.getRibbon().addTask(new RibbonTask("Command Strip", flowRibbonBand)); + + + RibbonApplicationMenu ribbonApplicationMenu = new RibbonApplicationMenu(commandGroup); + RibbonApplicationMenuCommand menuCommand = + RibbonApplicationMenuCommand.builder() + .setIconFactory(play_arrow.factory()).setText("Play") + .setSecondaryContentModel(ribbonApplicationMenu).build(); + + RibbonApplicationMenuCommandButtonProjection ribbonApplicationMenuCommandButtonProjection = + new RibbonApplicationMenuCommandButtonProjection(menuCommand, + CommandButtonPresentationModel.builder() + .setIconFilterStrategies( + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, + RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT) + .setPopupMenuPresentationModel(popupMenuPresentationModel).build()); + frame.getRibbon().setApplicationMenuCommand(ribbonApplicationMenuCommandButtonProjection); + + JPanel contentPanel = new JPanel(new BorderLayout()); + contentPanel.add(new JLabel("TESTING"), BorderLayout.CENTER); + + frame.getContentPane().add(contentPanel); + + frame.setSize(800, 600); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.setVisible(true); + + }); + } +} diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_forward.java b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_forward.java new file mode 100644 index 000000000..5f9c3dd9e --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_forward.java @@ -0,0 +1,242 @@ +package org.pushingpixels.radiance.demo.component.svg.material.transcoded; + +import java.awt.*; +import java.awt.geom.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.lang.ref.WeakReference; +import java.util.Base64; +import java.util.Stack; +import javax.imageio.ImageIO; +import javax.swing.SwingUtilities; +import javax.swing.plaf.UIResource; + +import org.pushingpixels.radiance.common.api.icon.RadianceIcon; +import org.pushingpixels.radiance.common.api.icon.RadianceIconUIResource; + +/** + * This class has been automatically generated using Radiance SVG transcoder. + */ +public class fast_forward implements RadianceIcon { + private Shape shape = null; + private GeneralPath generalPath = null; + private Paint paint = null; + private Stroke stroke = null; + private Shape clip = null; + private RadianceIcon.ColorFilter colorFilter = null; + private Stack transformsStack = new Stack<>(); + + + + private void _paint0(Graphics2D g,float origAlpha) { +// +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +transformsStack.push(g.getTransform()); +g.transform(new AffineTransform(0.02500000037252903f, 0.0f, 0.0f, 0.02500000037252903f, -0.0f, 24.00000035762787f)); +// _0 +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +// _0_0 +if (generalPath == null) { + generalPath = new GeneralPath(); +} else { + generalPath.reset(); +} +generalPath.moveTo(100.0f, -240.0f); +generalPath.lineTo(100.0f, -720.0f); +generalPath.lineTo(460.0f, -480.0f); +generalPath.lineTo(100.0f, -240.0f); +generalPath.closePath(); +generalPath.moveTo(500.0f, -240.0f); +generalPath.lineTo(500.0f, -720.0f); +generalPath.lineTo(860.0f, -480.0f); +generalPath.lineTo(500.0f, -240.0f); +generalPath.closePath(); +generalPath.moveTo(180.0f, -390.0f); +generalPath.lineTo(316.0f, -480.0f); +generalPath.lineTo(180.0f, -570.0f); +generalPath.lineTo(180.0f, -390.0f); +generalPath.closePath(); +generalPath.moveTo(580.0f, -390.0f); +generalPath.lineTo(716.0f, -480.0f); +generalPath.lineTo(580.0f, -570.0f); +generalPath.lineTo(580.0f, -390.0f); +generalPath.closePath(); +shape = generalPath; +paint = (colorFilter != null) ? colorFilter.filter(new Color(95, 99, 104, 255)) : new Color(95, 99, 104, 255); +g.setPaint(paint); +g.fill(shape); +g.setTransform(transformsStack.pop()); + +} + + + + @SuppressWarnings("unused") + private void innerPaint(Graphics2D g) { + float origAlpha = 1.0f; + Composite origComposite = g.getComposite(); + if (origComposite instanceof AlphaComposite) { + AlphaComposite origAlphaComposite = + (AlphaComposite)origComposite; + if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { + origAlpha = origAlphaComposite.getAlpha(); + } + } + + _paint0(g, origAlpha); + + + shape = null; + generalPath = null; + paint = null; + stroke = null; + clip = null; + transformsStack.clear(); + } + + /** + * Returns the X of the bounding box of the original SVG image. + * + * @return The X of the bounding box of the original SVG image. + */ + public static double getOrigX() { + return 2.5; + } + + /** + * Returns the Y of the bounding box of the original SVG image. + * + * @return The Y of the bounding box of the original SVG image. + */ + public static double getOrigY() { + return 6.0; + } + + /** + * Returns the width of the bounding box of the original SVG image. + * + * @return The width of the bounding box of the original SVG image. + */ + public static double getOrigWidth() { + return 19.0; + } + + /** + * Returns the height of the bounding box of the original SVG image. + * + * @return The height of the bounding box of the original SVG image. + */ + public static double getOrigHeight() { + return 12.0; + } + + /** The current width of this icon. */ + private int width; + + /** The current height of this icon. */ + private int height; + + /** + * Creates a new transcoded SVG image. This is marked as private to indicate that app + * code should be using the {@link #of(int, int)} method to obtain a pre-configured instance. + */ + private fast_forward() { + this.width = (int) getOrigWidth(); + this.height = (int) getOrigHeight(); + } + + @Override + public int getIconHeight() { + return height; + } + + @Override + public int getIconWidth() { + return width; + } + + @Override + public synchronized void setDimension(Dimension newDimension) { + this.width = newDimension.width; + this.height = newDimension.height; + } + + @Override + public boolean supportsColorFilter() { + return true; + } + + @Override + public void setColorFilter(ColorFilter colorFilter) { + this.colorFilter = colorFilter; + } + + @Override + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + g2d.translate(x, y); + + double coef1 = (double) this.width / getOrigWidth(); + double coef2 = (double) this.height / getOrigHeight(); + double coef = Math.min(coef1, coef2); + g2d.clipRect(0, 0, this.width, this.height); + g2d.scale(coef, coef); + g2d.translate(-getOrigX(), -getOrigY()); + if (coef1 != coef2) { + if (coef1 < coef2) { + int extraDy = (int) ((getOrigWidth() - getOrigHeight()) / 2.0); + g2d.translate(0, extraDy); + } else { + int extraDx = (int) ((getOrigHeight() - getOrigWidth()) / 2.0); + g2d.translate(extraDx, 0); + } + } + Graphics2D g2ForInner = (Graphics2D) g2d.create(); + innerPaint(g2ForInner); + g2ForInner.dispose(); + g2d.dispose(); + } + + /** + * Returns a new instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new instance of this icon with specified dimensions. + */ + public static RadianceIcon of(int width, int height) { + fast_forward base = new fast_forward(); + base.width = width; + base.height = height; + return base; + } + + /** + * Returns a new {@link UIResource} instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new {@link UIResource} instance of this icon with specified dimensions. + */ + public static RadianceIconUIResource uiResourceOf(int width, int height) { + fast_forward base = new fast_forward(); + base.width = width; + base.height = height; + return new RadianceIconUIResource(base); + } + + /** + * Returns a factory that returns instances of this icon on demand. + * + * @return Factory that returns instances of this icon on demand. + */ + public static Factory factory() { + return fast_forward::new; + } +} + diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_forward.svg b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_forward.svg new file mode 100644 index 000000000..b13d30b5c --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_forward.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_rewind.java b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_rewind.java new file mode 100644 index 000000000..bab1f1ad8 --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_rewind.java @@ -0,0 +1,242 @@ +package org.pushingpixels.radiance.demo.component.svg.material.transcoded; + +import java.awt.*; +import java.awt.geom.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.lang.ref.WeakReference; +import java.util.Base64; +import java.util.Stack; +import javax.imageio.ImageIO; +import javax.swing.SwingUtilities; +import javax.swing.plaf.UIResource; + +import org.pushingpixels.radiance.common.api.icon.RadianceIcon; +import org.pushingpixels.radiance.common.api.icon.RadianceIconUIResource; + +/** + * This class has been automatically generated using Radiance SVG transcoder. + */ +public class fast_rewind implements RadianceIcon { + private Shape shape = null; + private GeneralPath generalPath = null; + private Paint paint = null; + private Stroke stroke = null; + private Shape clip = null; + private RadianceIcon.ColorFilter colorFilter = null; + private Stack transformsStack = new Stack<>(); + + + + private void _paint0(Graphics2D g,float origAlpha) { +// +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +transformsStack.push(g.getTransform()); +g.transform(new AffineTransform(0.02500000037252903f, 0.0f, 0.0f, 0.02500000037252903f, -0.0f, 24.00000035762787f)); +// _0 +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +// _0_0 +if (generalPath == null) { + generalPath = new GeneralPath(); +} else { + generalPath.reset(); +} +generalPath.moveTo(860.0f, -240.0f); +generalPath.lineTo(500.0f, -480.0f); +generalPath.lineTo(860.0f, -720.0f); +generalPath.lineTo(860.0f, -240.0f); +generalPath.closePath(); +generalPath.moveTo(460.0f, -240.0f); +generalPath.lineTo(100.0f, -480.0f); +generalPath.lineTo(460.0f, -720.0f); +generalPath.lineTo(460.0f, -240.0f); +generalPath.closePath(); +generalPath.moveTo(380.0f, -390.0f); +generalPath.lineTo(380.0f, -570.0f); +generalPath.lineTo(244.0f, -480.0f); +generalPath.lineTo(380.0f, -390.0f); +generalPath.closePath(); +generalPath.moveTo(780.0f, -390.0f); +generalPath.lineTo(780.0f, -570.0f); +generalPath.lineTo(644.0f, -480.0f); +generalPath.lineTo(780.0f, -390.0f); +generalPath.closePath(); +shape = generalPath; +paint = (colorFilter != null) ? colorFilter.filter(new Color(95, 99, 104, 255)) : new Color(95, 99, 104, 255); +g.setPaint(paint); +g.fill(shape); +g.setTransform(transformsStack.pop()); + +} + + + + @SuppressWarnings("unused") + private void innerPaint(Graphics2D g) { + float origAlpha = 1.0f; + Composite origComposite = g.getComposite(); + if (origComposite instanceof AlphaComposite) { + AlphaComposite origAlphaComposite = + (AlphaComposite)origComposite; + if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { + origAlpha = origAlphaComposite.getAlpha(); + } + } + + _paint0(g, origAlpha); + + + shape = null; + generalPath = null; + paint = null; + stroke = null; + clip = null; + transformsStack.clear(); + } + + /** + * Returns the X of the bounding box of the original SVG image. + * + * @return The X of the bounding box of the original SVG image. + */ + public static double getOrigX() { + return 2.5; + } + + /** + * Returns the Y of the bounding box of the original SVG image. + * + * @return The Y of the bounding box of the original SVG image. + */ + public static double getOrigY() { + return 6.0; + } + + /** + * Returns the width of the bounding box of the original SVG image. + * + * @return The width of the bounding box of the original SVG image. + */ + public static double getOrigWidth() { + return 19.0; + } + + /** + * Returns the height of the bounding box of the original SVG image. + * + * @return The height of the bounding box of the original SVG image. + */ + public static double getOrigHeight() { + return 12.0; + } + + /** The current width of this icon. */ + private int width; + + /** The current height of this icon. */ + private int height; + + /** + * Creates a new transcoded SVG image. This is marked as private to indicate that app + * code should be using the {@link #of(int, int)} method to obtain a pre-configured instance. + */ + private fast_rewind() { + this.width = (int) getOrigWidth(); + this.height = (int) getOrigHeight(); + } + + @Override + public int getIconHeight() { + return height; + } + + @Override + public int getIconWidth() { + return width; + } + + @Override + public synchronized void setDimension(Dimension newDimension) { + this.width = newDimension.width; + this.height = newDimension.height; + } + + @Override + public boolean supportsColorFilter() { + return true; + } + + @Override + public void setColorFilter(ColorFilter colorFilter) { + this.colorFilter = colorFilter; + } + + @Override + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + g2d.translate(x, y); + + double coef1 = (double) this.width / getOrigWidth(); + double coef2 = (double) this.height / getOrigHeight(); + double coef = Math.min(coef1, coef2); + g2d.clipRect(0, 0, this.width, this.height); + g2d.scale(coef, coef); + g2d.translate(-getOrigX(), -getOrigY()); + if (coef1 != coef2) { + if (coef1 < coef2) { + int extraDy = (int) ((getOrigWidth() - getOrigHeight()) / 2.0); + g2d.translate(0, extraDy); + } else { + int extraDx = (int) ((getOrigHeight() - getOrigWidth()) / 2.0); + g2d.translate(extraDx, 0); + } + } + Graphics2D g2ForInner = (Graphics2D) g2d.create(); + innerPaint(g2ForInner); + g2ForInner.dispose(); + g2d.dispose(); + } + + /** + * Returns a new instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new instance of this icon with specified dimensions. + */ + public static RadianceIcon of(int width, int height) { + fast_rewind base = new fast_rewind(); + base.width = width; + base.height = height; + return base; + } + + /** + * Returns a new {@link UIResource} instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new {@link UIResource} instance of this icon with specified dimensions. + */ + public static RadianceIconUIResource uiResourceOf(int width, int height) { + fast_rewind base = new fast_rewind(); + base.width = width; + base.height = height; + return new RadianceIconUIResource(base); + } + + /** + * Returns a factory that returns instances of this icon on demand. + * + * @return Factory that returns instances of this icon on demand. + */ + public static Factory factory() { + return fast_rewind::new; + } +} + diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_rewind.svg b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_rewind.svg new file mode 100644 index 000000000..561309a4b --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/fast_rewind.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/play_arrow.java b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/play_arrow.java new file mode 100644 index 000000000..dc994ecb6 --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/play_arrow.java @@ -0,0 +1,232 @@ +package org.pushingpixels.radiance.demo.component.svg.material.transcoded; + +import java.awt.*; +import java.awt.geom.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.lang.ref.WeakReference; +import java.util.Base64; +import java.util.Stack; +import javax.imageio.ImageIO; +import javax.swing.SwingUtilities; +import javax.swing.plaf.UIResource; + +import org.pushingpixels.radiance.common.api.icon.RadianceIcon; +import org.pushingpixels.radiance.common.api.icon.RadianceIconUIResource; + +/** + * This class has been automatically generated using Radiance SVG transcoder. + */ +public class play_arrow implements RadianceIcon { + private Shape shape = null; + private GeneralPath generalPath = null; + private Paint paint = null; + private Stroke stroke = null; + private Shape clip = null; + private RadianceIcon.ColorFilter colorFilter = null; + private Stack transformsStack = new Stack<>(); + + + + private void _paint0(Graphics2D g,float origAlpha) { +// +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +transformsStack.push(g.getTransform()); +g.transform(new AffineTransform(0.02500000037252903f, 0.0f, 0.0f, 0.02500000037252903f, -0.0f, 24.00000035762787f)); +// _0 +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +// _0_0 +if (generalPath == null) { + generalPath = new GeneralPath(); +} else { + generalPath.reset(); +} +generalPath.moveTo(320.0f, -200.0f); +generalPath.lineTo(320.0f, -760.0f); +generalPath.lineTo(760.0f, -480.0f); +generalPath.lineTo(320.0f, -200.0f); +generalPath.closePath(); +generalPath.moveTo(400.0f, -346.0f); +generalPath.lineTo(610.0f, -480.0f); +generalPath.lineTo(400.0f, -614.0f); +generalPath.lineTo(400.0f, -346.0f); +generalPath.closePath(); +shape = generalPath; +paint = (colorFilter != null) ? colorFilter.filter(new Color(95, 99, 104, 255)) : new Color(95, 99, 104, 255); +g.setPaint(paint); +g.fill(shape); +g.setTransform(transformsStack.pop()); + +} + + + + @SuppressWarnings("unused") + private void innerPaint(Graphics2D g) { + float origAlpha = 1.0f; + Composite origComposite = g.getComposite(); + if (origComposite instanceof AlphaComposite) { + AlphaComposite origAlphaComposite = + (AlphaComposite)origComposite; + if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { + origAlpha = origAlphaComposite.getAlpha(); + } + } + + _paint0(g, origAlpha); + + + shape = null; + generalPath = null; + paint = null; + stroke = null; + clip = null; + transformsStack.clear(); + } + + /** + * Returns the X of the bounding box of the original SVG image. + * + * @return The X of the bounding box of the original SVG image. + */ + public static double getOrigX() { + return 8.0; + } + + /** + * Returns the Y of the bounding box of the original SVG image. + * + * @return The Y of the bounding box of the original SVG image. + */ + public static double getOrigY() { + return 5.0; + } + + /** + * Returns the width of the bounding box of the original SVG image. + * + * @return The width of the bounding box of the original SVG image. + */ + public static double getOrigWidth() { + return 11.0; + } + + /** + * Returns the height of the bounding box of the original SVG image. + * + * @return The height of the bounding box of the original SVG image. + */ + public static double getOrigHeight() { + return 14.0; + } + + /** The current width of this icon. */ + private int width; + + /** The current height of this icon. */ + private int height; + + /** + * Creates a new transcoded SVG image. This is marked as private to indicate that app + * code should be using the {@link #of(int, int)} method to obtain a pre-configured instance. + */ + private play_arrow() { + this.width = (int) getOrigWidth(); + this.height = (int) getOrigHeight(); + } + + @Override + public int getIconHeight() { + return height; + } + + @Override + public int getIconWidth() { + return width; + } + + @Override + public synchronized void setDimension(Dimension newDimension) { + this.width = newDimension.width; + this.height = newDimension.height; + } + + @Override + public boolean supportsColorFilter() { + return true; + } + + @Override + public void setColorFilter(ColorFilter colorFilter) { + this.colorFilter = colorFilter; + } + + @Override + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + g2d.translate(x, y); + + double coef1 = (double) this.width / getOrigWidth(); + double coef2 = (double) this.height / getOrigHeight(); + double coef = Math.min(coef1, coef2); + g2d.clipRect(0, 0, this.width, this.height); + g2d.scale(coef, coef); + g2d.translate(-getOrigX(), -getOrigY()); + if (coef1 != coef2) { + if (coef1 < coef2) { + int extraDy = (int) ((getOrigWidth() - getOrigHeight()) / 2.0); + g2d.translate(0, extraDy); + } else { + int extraDx = (int) ((getOrigHeight() - getOrigWidth()) / 2.0); + g2d.translate(extraDx, 0); + } + } + Graphics2D g2ForInner = (Graphics2D) g2d.create(); + innerPaint(g2ForInner); + g2ForInner.dispose(); + g2d.dispose(); + } + + /** + * Returns a new instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new instance of this icon with specified dimensions. + */ + public static RadianceIcon of(int width, int height) { + play_arrow base = new play_arrow(); + base.width = width; + base.height = height; + return base; + } + + /** + * Returns a new {@link UIResource} instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new {@link UIResource} instance of this icon with specified dimensions. + */ + public static RadianceIconUIResource uiResourceOf(int width, int height) { + play_arrow base = new play_arrow(); + base.width = width; + base.height = height; + return new RadianceIconUIResource(base); + } + + /** + * Returns a factory that returns instances of this icon on demand. + * + * @return Factory that returns instances of this icon on demand. + */ + public static Factory factory() { + return play_arrow::new; + } +} + diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/play_arrow.svg b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/play_arrow.svg new file mode 100644 index 000000000..117b492e8 --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/play_arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_next.java b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_next.java new file mode 100644 index 000000000..8f08aa07d --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_next.java @@ -0,0 +1,238 @@ +package org.pushingpixels.radiance.demo.component.svg.material.transcoded; + +import java.awt.*; +import java.awt.geom.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.lang.ref.WeakReference; +import java.util.Base64; +import java.util.Stack; +import javax.imageio.ImageIO; +import javax.swing.SwingUtilities; +import javax.swing.plaf.UIResource; + +import org.pushingpixels.radiance.common.api.icon.RadianceIcon; +import org.pushingpixels.radiance.common.api.icon.RadianceIconUIResource; + +/** + * This class has been automatically generated using Radiance SVG transcoder. + */ +public class skip_next implements RadianceIcon { + private Shape shape = null; + private GeneralPath generalPath = null; + private Paint paint = null; + private Stroke stroke = null; + private Shape clip = null; + private RadianceIcon.ColorFilter colorFilter = null; + private Stack transformsStack = new Stack<>(); + + + + private void _paint0(Graphics2D g,float origAlpha) { +// +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +transformsStack.push(g.getTransform()); +g.transform(new AffineTransform(0.02500000037252903f, 0.0f, 0.0f, 0.02500000037252903f, -0.0f, 24.00000035762787f)); +// _0 +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +// _0_0 +if (generalPath == null) { + generalPath = new GeneralPath(); +} else { + generalPath.reset(); +} +generalPath.moveTo(660.0f, -240.0f); +generalPath.lineTo(660.0f, -720.0f); +generalPath.lineTo(740.0f, -720.0f); +generalPath.lineTo(740.0f, -240.0f); +generalPath.lineTo(660.0f, -240.0f); +generalPath.closePath(); +generalPath.moveTo(220.0f, -240.0f); +generalPath.lineTo(220.0f, -720.0f); +generalPath.lineTo(580.0f, -480.0f); +generalPath.lineTo(220.0f, -240.0f); +generalPath.closePath(); +generalPath.moveTo(300.0f, -390.0f); +generalPath.lineTo(436.0f, -480.0f); +generalPath.lineTo(300.0f, -570.0f); +generalPath.lineTo(300.0f, -390.0f); +generalPath.closePath(); +shape = generalPath; +paint = (colorFilter != null) ? colorFilter.filter(new Color(95, 99, 104, 255)) : new Color(95, 99, 104, 255); +g.setPaint(paint); +g.fill(shape); +g.setTransform(transformsStack.pop()); + +} + + + + @SuppressWarnings("unused") + private void innerPaint(Graphics2D g) { + float origAlpha = 1.0f; + Composite origComposite = g.getComposite(); + if (origComposite instanceof AlphaComposite) { + AlphaComposite origAlphaComposite = + (AlphaComposite)origComposite; + if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { + origAlpha = origAlphaComposite.getAlpha(); + } + } + + _paint0(g, origAlpha); + + + shape = null; + generalPath = null; + paint = null; + stroke = null; + clip = null; + transformsStack.clear(); + } + + /** + * Returns the X of the bounding box of the original SVG image. + * + * @return The X of the bounding box of the original SVG image. + */ + public static double getOrigX() { + return 5.5; + } + + /** + * Returns the Y of the bounding box of the original SVG image. + * + * @return The Y of the bounding box of the original SVG image. + */ + public static double getOrigY() { + return 6.0; + } + + /** + * Returns the width of the bounding box of the original SVG image. + * + * @return The width of the bounding box of the original SVG image. + */ + public static double getOrigWidth() { + return 13.0; + } + + /** + * Returns the height of the bounding box of the original SVG image. + * + * @return The height of the bounding box of the original SVG image. + */ + public static double getOrigHeight() { + return 12.0; + } + + /** The current width of this icon. */ + private int width; + + /** The current height of this icon. */ + private int height; + + /** + * Creates a new transcoded SVG image. This is marked as private to indicate that app + * code should be using the {@link #of(int, int)} method to obtain a pre-configured instance. + */ + private skip_next() { + this.width = (int) getOrigWidth(); + this.height = (int) getOrigHeight(); + } + + @Override + public int getIconHeight() { + return height; + } + + @Override + public int getIconWidth() { + return width; + } + + @Override + public synchronized void setDimension(Dimension newDimension) { + this.width = newDimension.width; + this.height = newDimension.height; + } + + @Override + public boolean supportsColorFilter() { + return true; + } + + @Override + public void setColorFilter(ColorFilter colorFilter) { + this.colorFilter = colorFilter; + } + + @Override + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + g2d.translate(x, y); + + double coef1 = (double) this.width / getOrigWidth(); + double coef2 = (double) this.height / getOrigHeight(); + double coef = Math.min(coef1, coef2); + g2d.clipRect(0, 0, this.width, this.height); + g2d.scale(coef, coef); + g2d.translate(-getOrigX(), -getOrigY()); + if (coef1 != coef2) { + if (coef1 < coef2) { + int extraDy = (int) ((getOrigWidth() - getOrigHeight()) / 2.0); + g2d.translate(0, extraDy); + } else { + int extraDx = (int) ((getOrigHeight() - getOrigWidth()) / 2.0); + g2d.translate(extraDx, 0); + } + } + Graphics2D g2ForInner = (Graphics2D) g2d.create(); + innerPaint(g2ForInner); + g2ForInner.dispose(); + g2d.dispose(); + } + + /** + * Returns a new instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new instance of this icon with specified dimensions. + */ + public static RadianceIcon of(int width, int height) { + skip_next base = new skip_next(); + base.width = width; + base.height = height; + return base; + } + + /** + * Returns a new {@link UIResource} instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new {@link UIResource} instance of this icon with specified dimensions. + */ + public static RadianceIconUIResource uiResourceOf(int width, int height) { + skip_next base = new skip_next(); + base.width = width; + base.height = height; + return new RadianceIconUIResource(base); + } + + /** + * Returns a factory that returns instances of this icon on demand. + * + * @return Factory that returns instances of this icon on demand. + */ + public static Factory factory() { + return skip_next::new; + } +} + diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_next.svg b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_next.svg new file mode 100644 index 000000000..1063e6e53 --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_next.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_previous.java b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_previous.java new file mode 100644 index 000000000..2da594202 --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_previous.java @@ -0,0 +1,238 @@ +package org.pushingpixels.radiance.demo.component.svg.material.transcoded; + +import java.awt.*; +import java.awt.geom.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.lang.ref.WeakReference; +import java.util.Base64; +import java.util.Stack; +import javax.imageio.ImageIO; +import javax.swing.SwingUtilities; +import javax.swing.plaf.UIResource; + +import org.pushingpixels.radiance.common.api.icon.RadianceIcon; +import org.pushingpixels.radiance.common.api.icon.RadianceIconUIResource; + +/** + * This class has been automatically generated using Radiance SVG transcoder. + */ +public class skip_previous implements RadianceIcon { + private Shape shape = null; + private GeneralPath generalPath = null; + private Paint paint = null; + private Stroke stroke = null; + private Shape clip = null; + private RadianceIcon.ColorFilter colorFilter = null; + private Stack transformsStack = new Stack<>(); + + + + private void _paint0(Graphics2D g,float origAlpha) { +// +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +transformsStack.push(g.getTransform()); +g.transform(new AffineTransform(0.02500000037252903f, 0.0f, 0.0f, 0.02500000037252903f, -0.0f, 24.00000035762787f)); +// _0 +g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); +// _0_0 +if (generalPath == null) { + generalPath = new GeneralPath(); +} else { + generalPath.reset(); +} +generalPath.moveTo(220.0f, -240.0f); +generalPath.lineTo(220.0f, -720.0f); +generalPath.lineTo(300.0f, -720.0f); +generalPath.lineTo(300.0f, -240.0f); +generalPath.lineTo(220.0f, -240.0f); +generalPath.closePath(); +generalPath.moveTo(740.0f, -240.0f); +generalPath.lineTo(380.0f, -480.0f); +generalPath.lineTo(740.0f, -720.0f); +generalPath.lineTo(740.0f, -240.0f); +generalPath.closePath(); +generalPath.moveTo(660.0f, -390.0f); +generalPath.lineTo(660.0f, -570.0f); +generalPath.lineTo(524.0f, -480.0f); +generalPath.lineTo(660.0f, -390.0f); +generalPath.closePath(); +shape = generalPath; +paint = (colorFilter != null) ? colorFilter.filter(new Color(95, 99, 104, 255)) : new Color(95, 99, 104, 255); +g.setPaint(paint); +g.fill(shape); +g.setTransform(transformsStack.pop()); + +} + + + + @SuppressWarnings("unused") + private void innerPaint(Graphics2D g) { + float origAlpha = 1.0f; + Composite origComposite = g.getComposite(); + if (origComposite instanceof AlphaComposite) { + AlphaComposite origAlphaComposite = + (AlphaComposite)origComposite; + if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { + origAlpha = origAlphaComposite.getAlpha(); + } + } + + _paint0(g, origAlpha); + + + shape = null; + generalPath = null; + paint = null; + stroke = null; + clip = null; + transformsStack.clear(); + } + + /** + * Returns the X of the bounding box of the original SVG image. + * + * @return The X of the bounding box of the original SVG image. + */ + public static double getOrigX() { + return 5.5; + } + + /** + * Returns the Y of the bounding box of the original SVG image. + * + * @return The Y of the bounding box of the original SVG image. + */ + public static double getOrigY() { + return 6.0; + } + + /** + * Returns the width of the bounding box of the original SVG image. + * + * @return The width of the bounding box of the original SVG image. + */ + public static double getOrigWidth() { + return 13.0; + } + + /** + * Returns the height of the bounding box of the original SVG image. + * + * @return The height of the bounding box of the original SVG image. + */ + public static double getOrigHeight() { + return 12.0; + } + + /** The current width of this icon. */ + private int width; + + /** The current height of this icon. */ + private int height; + + /** + * Creates a new transcoded SVG image. This is marked as private to indicate that app + * code should be using the {@link #of(int, int)} method to obtain a pre-configured instance. + */ + private skip_previous() { + this.width = (int) getOrigWidth(); + this.height = (int) getOrigHeight(); + } + + @Override + public int getIconHeight() { + return height; + } + + @Override + public int getIconWidth() { + return width; + } + + @Override + public synchronized void setDimension(Dimension newDimension) { + this.width = newDimension.width; + this.height = newDimension.height; + } + + @Override + public boolean supportsColorFilter() { + return true; + } + + @Override + public void setColorFilter(ColorFilter colorFilter) { + this.colorFilter = colorFilter; + } + + @Override + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + g2d.translate(x, y); + + double coef1 = (double) this.width / getOrigWidth(); + double coef2 = (double) this.height / getOrigHeight(); + double coef = Math.min(coef1, coef2); + g2d.clipRect(0, 0, this.width, this.height); + g2d.scale(coef, coef); + g2d.translate(-getOrigX(), -getOrigY()); + if (coef1 != coef2) { + if (coef1 < coef2) { + int extraDy = (int) ((getOrigWidth() - getOrigHeight()) / 2.0); + g2d.translate(0, extraDy); + } else { + int extraDx = (int) ((getOrigHeight() - getOrigWidth()) / 2.0); + g2d.translate(extraDx, 0); + } + } + Graphics2D g2ForInner = (Graphics2D) g2d.create(); + innerPaint(g2ForInner); + g2ForInner.dispose(); + g2d.dispose(); + } + + /** + * Returns a new instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new instance of this icon with specified dimensions. + */ + public static RadianceIcon of(int width, int height) { + skip_previous base = new skip_previous(); + base.width = width; + base.height = height; + return base; + } + + /** + * Returns a new {@link UIResource} instance of this icon with specified dimensions. + * + * @param width Required width of the icon + * @param height Required height of the icon + * @return A new {@link UIResource} instance of this icon with specified dimensions. + */ + public static RadianceIconUIResource uiResourceOf(int width, int height) { + skip_previous base = new skip_previous(); + base.width = width; + base.height = height; + return new RadianceIconUIResource(base); + } + + /** + * Returns a factory that returns instances of this icon on demand. + * + * @return Factory that returns instances of this icon on demand. + */ + public static Factory factory() { + return skip_previous::new; + } +} + diff --git a/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_previous.svg b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_previous.svg new file mode 100644 index 000000000..0b28aa90f --- /dev/null +++ b/demos/component-demo/src/main/java/org/pushingpixels/radiance/demo/component/svg/material/transcoded/skip_previous.svg @@ -0,0 +1 @@ + \ No newline at end of file