Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Apr 18, 2023
1 parent ad77711 commit fe63390
Show file tree
Hide file tree
Showing 105 changed files with 24,681 additions and 25,494 deletions.
3,972 changes: 1,966 additions & 2,006 deletions Project/src/main/java/com/github/lgooddatepicker/components/CalendarPanel.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
package com.github.lgooddatepicker.components;

import com.github.lgooddatepicker.zinternaltools.Pair;

import java.awt.Image;
import java.beans.BeanDescriptor;
import java.beans.BeanInfo;
Expand All @@ -46,155 +45,153 @@
*/
public class CalendarPanelBeanInfo extends SimpleBeanInfo {

///////////////////////////////////////////////////////////////////////////////////////////////
// Start: Custom settings.
///////////////////////////////////////////////////////////////////////////////////////////////
/**
* iconInformation, This holds all the information for the image icons. The map key is the
* BeanInfo icon type. The pair string is the path to the matching icon resource. The pair image
* will hold the matching icon image, if it has been loaded. (The image will be null until the
* first time it is loaded.)
*/
private static HashMap<Integer, Pair<String, Image>> iconInformation =
new HashMap<Integer, Pair<String, Image>>() {
{
put(ICON_MONO_16x16, new Pair<>("/images/CalendarPanelIcon 16x16.png", null));
put(ICON_COLOR_16x16, new Pair<>("/images/CalendarPanelIcon 16x16.png", null));
put(ICON_MONO_32x32, new Pair<>("/images/CalendarPanelIcon 32x32.png", null));
put(ICON_COLOR_32x32, new Pair<>("/images/CalendarPanelIcon 32x32.png", null));
}
};

/**
* preferredProperties, This lists all the properties that should be marked as preferred, as
* lowercase strings. Any properties that are not in this list, will be marked as "not
* preferred". (All of the defaults for preferred properties are overwritten.)
*/
private static HashSet<String> preferredProperties =
new HashSet<>(Arrays.asList("selecteddate"));

/**
* propertyDescriptions, These are the descriptions to add to the properties. The key is the
* property name in all lowercase. The value is the property description.
*/
private static HashMap<String, String> propertyDescriptions =
new HashMap<String, String>() {
{
put("selecteddate", "The selected date in the calendar.");
}
};

/** targetClass, This is the class for which we are providing the BeanInfo. */
private static Class targetClass = CalendarPanel.class;

///////////////////////////////////////////////////////////////////////////////////////////////
// End: Custom settings.
///////////////////////////////////////////////////////////////////////////////////////////////
/**
* zDefaultEventIndex, This holds the BeanInfo defaultEventIndex. This is initialized when the
* class is first loaded, and not changed afterwards.
*/
private static int zDefaultEventIndex = -1;

/**
* zDefaultPropertyIndex, This holds the BeanInfo defaultPropertyIndex. This is initialized when
* the class is first loaded, and not changed afterwards.
*/
private static int zDefaultPropertyIndex = -1;

/**
* zPropertyDescriptorArray, This holds the array of BeanInfo property descriptors. This is
* initialized when the class is first loaded, and not changed afterwards.
*/
private static PropertyDescriptor[] zPropertyDescriptorArray;

/**
* Static Initializer, This code is run when the class is first accessed or instantiated. This
* initializes all the needed BeanInfo arrays.
*/
static {
try {
BeanInfo info = Introspector.getBeanInfo(targetClass);
zPropertyDescriptorArray = info.getPropertyDescriptors();
} catch (IntrospectionException ex) {
throw new RuntimeException(ex.getMessage());
}
for (PropertyDescriptor propertyDescriptor : zPropertyDescriptorArray) {
String propertyName = propertyDescriptor.getName().toLowerCase();
propertyDescriptor.setPreferred(preferredProperties.contains(propertyName));
if (propertyDescriptions.containsKey(propertyName)) {
propertyDescriptor.setShortDescription(propertyDescriptions.get(propertyName));
}
///////////////////////////////////////////////////////////////////////////////////////////////
// Start: Custom settings.
///////////////////////////////////////////////////////////////////////////////////////////////
/**
* iconInformation, This holds all the information for the image icons. The map key is the
* BeanInfo icon type. The pair string is the path to the matching icon resource. The pair image
* will hold the matching icon image, if it has been loaded. (The image will be null until the
* first time it is loaded.)
*/
private static HashMap<Integer, Pair<String, Image>> iconInformation =
new HashMap<Integer, Pair<String, Image>>() {
{
put(ICON_MONO_16x16, new Pair<>("/images/CalendarPanelIcon 16x16.png", null));
put(ICON_COLOR_16x16, new Pair<>("/images/CalendarPanelIcon 16x16.png", null));
put(ICON_MONO_32x32, new Pair<>("/images/CalendarPanelIcon 32x32.png", null));
put(ICON_COLOR_32x32, new Pair<>("/images/CalendarPanelIcon 32x32.png", null));
}
}

/**
* getIcon, Returns the requested BeanInfo icon type, or null if an icon does not exist or
* cannot be retrieved.
*/
@Override
public Image getIcon(int iconType) {
Pair<String, Image> pair = iconInformation.get(iconType);
String imagePath = pair.first;
Image imageOrNull = pair.second;
if ((imageOrNull == null) && (imagePath != null)) {
imageOrNull = loadImage(imagePath);
};

/**
* preferredProperties, This lists all the properties that should be marked as preferred, as
* lowercase strings. Any properties that are not in this list, will be marked as "not preferred".
* (All of the defaults for preferred properties are overwritten.)
*/
private static HashSet<String> preferredProperties = new HashSet<>(Arrays.asList("selecteddate"));

/**
* propertyDescriptions, These are the descriptions to add to the properties. The key is the
* property name in all lowercase. The value is the property description.
*/
private static HashMap<String, String> propertyDescriptions =
new HashMap<String, String>() {
{
put("selecteddate", "The selected date in the calendar.");
}
return imageOrNull;
}

/**
* getBeanDescriptor, Returns the BeanInfo BeanDescriptor, or null to use automatic
* introspection.
*/
@Override
public BeanDescriptor getBeanDescriptor() {
return null;
}

/**
* getPropertyDescriptors, Returns the BeanInfo PropertyDescriptor array, or null to use
* automatic introspection. Each array element may be a PropertyDescriptor, or the
* IndexedPropertyDescriptor subclass of PropertyDescriptor.
*/
@Override
public PropertyDescriptor[] getPropertyDescriptors() {
return zPropertyDescriptorArray;
}

/**
* getEventSetDescriptors, Returns the BeanInfo EventSetDescriptor array, or null to use
* automatic introspection.
*/
@Override
public EventSetDescriptor[] getEventSetDescriptors() {
return null;
};

/** targetClass, This is the class for which we are providing the BeanInfo. */
private static Class targetClass = CalendarPanel.class;

///////////////////////////////////////////////////////////////////////////////////////////////
// End: Custom settings.
///////////////////////////////////////////////////////////////////////////////////////////////
/**
* zDefaultEventIndex, This holds the BeanInfo defaultEventIndex. This is initialized when the
* class is first loaded, and not changed afterwards.
*/
private static int zDefaultEventIndex = -1;

/**
* zDefaultPropertyIndex, This holds the BeanInfo defaultPropertyIndex. This is initialized when
* the class is first loaded, and not changed afterwards.
*/
private static int zDefaultPropertyIndex = -1;

/**
* zPropertyDescriptorArray, This holds the array of BeanInfo property descriptors. This is
* initialized when the class is first loaded, and not changed afterwards.
*/
private static PropertyDescriptor[] zPropertyDescriptorArray;

/**
* Static Initializer, This code is run when the class is first accessed or instantiated. This
* initializes all the needed BeanInfo arrays.
*/
static {
try {
BeanInfo info = Introspector.getBeanInfo(targetClass);
zPropertyDescriptorArray = info.getPropertyDescriptors();
} catch (IntrospectionException ex) {
throw new RuntimeException(ex.getMessage());
}

/**
* getMethodDescriptors, Returns the BeanInfo MethodDescriptor array, or null to use automatic
* introspection.
*/
@Override
public MethodDescriptor[] getMethodDescriptors() {
return null;
for (PropertyDescriptor propertyDescriptor : zPropertyDescriptorArray) {
String propertyName = propertyDescriptor.getName().toLowerCase();
propertyDescriptor.setPreferred(preferredProperties.contains(propertyName));
if (propertyDescriptions.containsKey(propertyName)) {
propertyDescriptor.setShortDescription(propertyDescriptions.get(propertyName));
}
}

/**
* getDefaultPropertyIndex, Returns the BeanInfo defaultPropertyIndex, or -1 if there is no
* default property.
*/
@Override
public int getDefaultPropertyIndex() {
return zDefaultPropertyIndex;
}

/**
* getDefaultEventIndex, Returns the BeanInfo defaultEventIndex, or -1 if there is no default
* property.
*/
@Override
public int getDefaultEventIndex() {
return zDefaultEventIndex;
}

/**
* getIcon, Returns the requested BeanInfo icon type, or null if an icon does not exist or cannot
* be retrieved.
*/
@Override
public Image getIcon(int iconType) {
Pair<String, Image> pair = iconInformation.get(iconType);
String imagePath = pair.first;
Image imageOrNull = pair.second;
if ((imageOrNull == null) && (imagePath != null)) {
imageOrNull = loadImage(imagePath);
}
return imageOrNull;
}

/**
* getBeanDescriptor, Returns the BeanInfo BeanDescriptor, or null to use automatic introspection.
*/
@Override
public BeanDescriptor getBeanDescriptor() {
return null;
}

/**
* getPropertyDescriptors, Returns the BeanInfo PropertyDescriptor array, or null to use automatic
* introspection. Each array element may be a PropertyDescriptor, or the IndexedPropertyDescriptor
* subclass of PropertyDescriptor.
*/
@Override
public PropertyDescriptor[] getPropertyDescriptors() {
return zPropertyDescriptorArray;
}

/**
* getEventSetDescriptors, Returns the BeanInfo EventSetDescriptor array, or null to use automatic
* introspection.
*/
@Override
public EventSetDescriptor[] getEventSetDescriptors() {
return null;
}

/**
* getMethodDescriptors, Returns the BeanInfo MethodDescriptor array, or null to use automatic
* introspection.
*/
@Override
public MethodDescriptor[] getMethodDescriptors() {
return null;
}

/**
* getDefaultPropertyIndex, Returns the BeanInfo defaultPropertyIndex, or -1 if there is no
* default property.
*/
@Override
public int getDefaultPropertyIndex() {
return zDefaultPropertyIndex;
}

/**
* getDefaultEventIndex, Returns the BeanInfo defaultEventIndex, or -1 if there is no default
* property.
*/
@Override
public int getDefaultEventIndex() {
return zDefaultEventIndex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@
*/
public class ComponentEvent {

public static final int PREVIOUS_YEAR = 1;
public static final int PREVIOUS_MONTH = 2;
public static final int NEXT_MONTH = 3;
public static final int NEXT_YEAR = 4;
public static final int PREVIOUS_YEAR = 1;
public static final int PREVIOUS_MONTH = 2;
public static final int NEXT_MONTH = 3;
public static final int NEXT_YEAR = 4;

private int what;
private JComponent component;
private int what;
private JComponent component;

public ComponentEvent(int what, JComponent component) {
this.what = what;
this.component = component;
}
public ComponentEvent(int what, JComponent component) {
this.what = what;
this.component = component;
}

public int getWhat() {
return what;
}
public int getWhat() {
return what;
}

public JComponent getComponent() {
return component;
}
public JComponent getComponent() {
return component;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
*/
public interface ComponentListener {

public void componentCreated(ComponentEvent e);
public void componentCreated(ComponentEvent e);
}
Loading

0 comments on commit fe63390

Please sign in to comment.