Class ComponentScaler

java.lang.Object
org.vanted.scaling.scalers.BasicScaler
org.vanted.scaling.scalers.component.ComponentScaler
All Implemented Interfaces:
Scaler
Direct Known Subclasses:
AbstractButtonScaler, JLabelScaler, JOptionPaneScaler, JSplitPaneScaler, JTabbedPaneScaler, JTextComponentScaler, WindowScaler

public class ComponentScaler
extends BasicScaler
Applicable to initiated Swing Components. It scales specifics that have been overwritten by design only, making sure LAF-Defaults are not scaled again. So, it is a kind of co-scaler to any of the LAF-Scalers.

To obtain a scaling factor, you could call DPIHelper.getDPIScalingRatio() Current (default) subtypes:

AbstractButtonScaler
JLabelScaler
JOptionPaneScaler
JSplitPaneScaler
JTabbedPaneScaler
JTextComponentScaler

Author:
D. Garkov
  • Constructor Details

    • ComponentScaler

      public ComponentScaler​(float scaleFactor)
  • Method Details

    • scaleComponent

      public void scaleComponent​(JComponent immediateComponent)
      A method to be called when this ComponentScaler has been dispatched to some immediate JComponent to be scaled - both from the central ComponentRegulator and on its own. A reason for a call outside the usual scaling routine could be an initialization of new components with overwritten, i.e custom-set, LAF Defaults, post-scaling. Attach a scaler and call this method after done with the initialization. For more specific JComponents, see the direct known subclasses.
      Parameters:
      immediateComponent - to be scaled
    • coscaleFont

      public void coscaleFont​(JComponent component)
      Scales all components that have their font not modified by the LAF-Scalers for one reason or another up to this point.
      Parameters:
      component - the JComponent, whose Font is to be scaled
    • coscaleInsets

      public void coscaleInsets​(JComponent component)
      Modifies non-null Insets of JComponent.
      Parameters:
      component - the JComponent, whose Insets are to be scaled
    • coscaleIcon

      public void coscaleIcon​(JComponent component)
      Left to subtypes. There are implementations for the following JComponents:

      AbstractButton, JLabel, JOptionPane, JTabbedPane.

      Parameters:
      component - Component having Icon