/** * @return the input modifier to distinguish between scroll events and zoom * events. */ private int getMouseWheelZoomModifier() { final HostInfo hostInfo = HostUtils.getHostInfo(); if ( hostInfo.isMacOS() ) { return InputEvent.META_DOWN_MASK; } return InputEvent.CTRL_DOWN_MASK; }
/** * {@inheritDoc} */ public final boolean needsExitMenuItem() { return !isMacOS(); }
/** * @param aTableRow * @param aIdx * @param aSampleIdx * @param aValue */ private void addDataValues( final Element aTableRow, final int aIdx, final int aSampleIdx, final int aValue ) { aTableRow.addChild( TD ).addContent( "0x", integerToHexString( aValue, ( bitCount / 4 ) + bitAdder ) ); aTableRow.addChild( TD ).addContent( "0b", integerToBinString( aValue, bitCount ) ); aTableRow.addChild( TD ).addContent( String.valueOf( aValue ) ); aTableRow.addChild( TD ).addContent( toASCII( aValue ) ); } };
/** * Parses the given text as an integer, avoiding runtime exceptions. * * @param aText * the text to parse as an integer, can be <code>null</code> or * empty. * @return the numeric representation of the given text, or -1 if the text * could not be parsed correctly as integer. * @see #safeParseInt(String, int) */ public static int safeParseInt( final String aText ) { return safeParseInt( aText, -1 ); }
/** * Returns the number of samples to take. * * @return the sample depth, >= 0. */ public int getSampleDepth() { return NumberUtils.smartParseInt( this.sampleDepth.getText(), 1024 ); }
/** * Parses the given text as an integer, avoiding runtime exceptions. * * @param aText * the text to parse as an integer, can be <code>null</code> or * empty. * @return the numeric representation of the given text, or -1 if the text * could not be parsed correctly as integer. * @see #safeParseLong(String, long) */ public static long safeParseLong( final String aText ) { return safeParseLong( aText, -1L ); }
/** * Returns the file-object pointing to a user-settings file. * * @return a user-settings file-object, never <code>null</code>. */ private File getUserSettingsFile() { return HostUtils.createLocalDataFile( IMPLICIT_USER_SETTING_NAME_PREFIX, IMPLICIT_USER_SETTING_NAME_SUFFIX ); }
/** * Sets color to the given value. * * @param aColor * the color (as hex triplet) to set. */ public final void setColor( final String aColor ) { setColor( ColorUtils.parseColor( aColor ) ); }
/** * {@inheritDoc} */ @Override public void componentShown( final ComponentEvent aEvent ) { this.repaintQueue.add( aEvent ); }
/** * Factory method to create a new pair of two given values. * * @param aLeft * the left-hand side of the pair; * @param aRight * the right-hand side of the pair. * @return a new pair instance, never <code>null</code>. */ public static <T, V> Pair<T, V> of( final T aLeft, final V aRight ) { return new Pair<T, V>( aLeft, aRight ); }
/** * Removes all double quotes from the given input. * * @param aInput * the input string to remove the quotes from, may be * <code>null</code>. * @return the unquoted version of the given input, or <code>null</code> if * the original input was <code>null</code>. * @see #unquote(String, char) */ public static String unquote( final String aInput ) { return unquote( aInput, '"' ); }
/** * Creates a number comparator that can be used to sort a list of numbers in * ascending or descending order. * * @param <T> * the exact numeric type to sort on; * @param aSortAscending * <code>true</code> if the numbers should be sorted ascendingly, * <code>false</code> if the numbers should be sorted in descending * order. * @return a comparator instance, never <code>null</code>. */ public static <T extends Number> Comparator<T> createNumberComparator( final boolean aSortAscending ) { return new NumericComparator<T>( aSortAscending ); }
/** * Returns the text color for a cursor with the given index. * * @param aCursorIndex * the index of the cursor to retrieve the color for. * @return a cursor text color, never <code>null</code>. */ public Color getCursorTextColor( final int aCursorIndex ) { return ColorUtils.getContrastColor( getCursorColor( aCursorIndex ) ); }
/** * Returns the number of channels in each sample. * * @return the channel count, >= 0. */ public int getChannelCount() { return NumberUtils.safeParseInt( this.channelCount.getText(), 8 ); }
/** * @return the selected sample rate, in Hertz. */ private int getSelectedSampleRate() { final String value = getComboBoxText( this.speedSelect ); return NumberUtils.smartParseInt( value, UnitDefinition.SI, SumpProtocolConstants.CLOCK ); }
/** * Creates an OS-specific file location to store properties. * * @param aName * the name of the properties file, excluding <tt>.properties</tt>, * cannot be <code>null</code> or empty. By convention, the name of a * properties file should be in the "reverse package name", e.g., * "com.foo.bar". * @return the file pointing to the OS-specific properties file location, * never <code>null</code>. */ public static final File createLocalPropertiesFile( final String aName ) { return createLocalDataFile( aName, "properties" ); }
/** * {@inheritDoc} */ @Override public boolean needsAboutMenuItem() { return !isMacOS(); }
/** * {@inheritDoc} */ @Override public void componentResized( final ComponentEvent aEvent ) { this.repaintQueue.add( aEvent ); }
/** * {@inheritDoc} */ @Override public boolean needsPreferencesMenuItem() { return !isMacOS(); } }