idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
30,200
@ SuppressWarnings ( "unchecked" ) public SpringCache2kCache getCache ( final String name ) { return name2cache . computeIfAbsent ( name , n -> { if ( ! allowUnknownCache && ! configuredCacheNames . contains ( n ) ) { throw new IllegalArgumentException ( "Cache configuration missing for: " + n ) ; } return buildAndWrap ( Cache2kBuilder . forUnknownTypes ( ) . manager ( manager ) . name ( n ) ) ; } ) ; }
Returns an existing cache or retrieves and wraps a cache from cache2k .
30,201
public Collection < String > getCacheNames ( ) { Set < String > cacheNames = new HashSet < > ( ) ; for ( org . cache2k . Cache < ? , ? > cache : manager . getActiveCaches ( ) ) { cacheNames . add ( cache . getName ( ) ) ; } cacheNames . addAll ( configuredCacheNames ) ; return Collections . unmodifiableSet ( cacheNames ) ; }
Get a list of known caches . Depending on the configuration caches may be created dynamically without providing a configuration for a specific cache name . Because of this combine the known names from configuration and activated caches .
30,202
@ SuppressWarnings ( "unchecked" ) public < C extends Configuration < K , T > > C getConfiguration ( Class < C > clazz ) { final C c = cache . getConfiguration ( clazz ) ; if ( c instanceof CompleteConfiguration ) { final CompleteConfiguration < K , T > cc = ( CompleteConfiguration < K , T > ) c ; return ( C ) new CompleteConfiguration < K , T > ( ) { public Iterable < CacheEntryListenerConfiguration < K , T > > getCacheEntryListenerConfigurations ( ) { return cc . getCacheEntryListenerConfigurations ( ) ; } public boolean isReadThrough ( ) { return cc . isReadThrough ( ) ; } public boolean isWriteThrough ( ) { return cc . isWriteThrough ( ) ; } public boolean isStatisticsEnabled ( ) { return cc . isStatisticsEnabled ( ) ; } public boolean isManagementEnabled ( ) { return cc . isManagementEnabled ( ) ; } public Factory < CacheLoader < K , T > > getCacheLoaderFactory ( ) { return cc . getCacheLoaderFactory ( ) ; } public Factory < CacheWriter < ? super K , ? super T > > getCacheWriterFactory ( ) { return cc . getCacheWriterFactory ( ) ; } public Factory < ExpiryPolicy > getExpiryPolicyFactory ( ) { return cc . getExpiryPolicyFactory ( ) ; } public Class < K > getKeyType ( ) { return cc . getKeyType ( ) ; } public Class < T > getValueType ( ) { return cc . getValueType ( ) ; } public boolean isStoreByValue ( ) { return true ; } } ; } else if ( c instanceof Configuration ) { return ( C ) new Configuration < K , T > ( ) { public Class < K > getKeyType ( ) { return c . getKeyType ( ) ; } public Class < T > getValueType ( ) { return c . getValueType ( ) ; } public boolean isStoreByValue ( ) { return true ; } } ; } return c ; }
Delegates to the wrapped cache . Wrap configuration and return true on store by value
30,203
public static < K , V > Cache2kConfiguration < K , V > of ( CacheType < K > keyType , CacheType < V > valueType ) { Cache2kConfiguration < K , V > c = new Cache2kConfiguration < K , V > ( ) ; c . setKeyType ( keyType ) ; c . setValueType ( valueType ) ; return c ; }
Construct a config instance setting the type parameters and returning a proper generic type .
30,204
public CustomizationCollection < CacheEntryOperationListener < K , V > > getListeners ( ) { if ( listeners == null ) { listeners = new DefaultCustomizationCollection < CacheEntryOperationListener < K , V > > ( ) ; } return listeners ; }
A set of listeners . Listeners added in this collection will be executed in a synchronous mode meaning further processing for an entry will stall until a registered listener is executed . The expiry will be always executed asynchronously .
30,205
public static synchronized void reload ( ) { map = new HashMap < Class < ? > , Object > ( ) ; customProperties = loadFile ( CUSTOM_TUNING_FILE_NAME ) ; defaultProperties = loadFile ( DEFAULT_TUNING_FILE_NAME ) ; }
Reload the tunable configuration from the system properties and the configuration file .
30,206
@ SuppressWarnings ( "unchecked" ) public synchronized static < T extends TunableConstants > T get ( Properties p , Class < T > c ) { T cfg = getDefault ( c ) ; if ( p != null && p . containsKey ( TUNE_MARKER ) && p . containsKey ( cfg . getClass ( ) . getName ( ) + ".tuning" ) ) { cfg = ( T ) cfg . clone ( ) ; apply ( p , cfg ) ; } return cfg ; }
Provide tuning object with initialized information from the properties file .
30,207
public boolean add ( ConfigurationSection section ) { if ( section instanceof SingletonConfigurationSection ) { if ( getSection ( section . getClass ( ) ) != null ) { throw new IllegalArgumentException ( "Section of same type already inserted: " + section . getClass ( ) . getName ( ) ) ; } } return sections . add ( section ) ; }
Add a new configuration section to the container .
30,208
@ SuppressWarnings ( "unchecked" ) public < T extends ConfigurationSection > T getSection ( Class < T > sectionType ) { for ( ConfigurationSection s : sections ) { if ( sectionType . equals ( s . getClass ( ) ) ) { return ( T ) s ; } } return null ; }
Retrieve a single section from the container .
30,209
void deliverAsyncEvent ( final EntryEvent < K , V > _event ) { if ( asyncListenerByType . get ( _event . getEventType ( ) ) . isEmpty ( ) ) { return ; } List < Listener < K , V > > _listeners = new ArrayList < Listener < K , V > > ( asyncListenerByType . get ( _event . getEventType ( ) ) ) ; if ( _listeners . isEmpty ( ) ) { return ; } K key = _event . getKey ( ) ; synchronized ( getLockObject ( key ) ) { Queue < EntryEvent < K , V > > q = keyQueue . get ( key ) ; if ( q != null ) { q . add ( _event ) ; return ; } q = new LinkedList < EntryEvent < K , V > > ( ) ; keyQueue . put ( key , q ) ; } runAllListenersInParallel ( _event , _listeners ) ; }
If listeners are registered for this event type run the listeners or queue the event if already something is happening for this key .
30,210
void runAllListenersInParallel ( final EntryEvent < K , V > _event , List < Listener < K , V > > _listeners ) { final AtomicInteger _countDown = new AtomicInteger ( _listeners . size ( ) ) ; for ( final Listener < K , V > l : _listeners ) { Runnable r = new Runnable ( ) { public void run ( ) { try { l . fire ( _event ) ; } catch ( Throwable t ) { t . printStackTrace ( ) ; } int _done = _countDown . decrementAndGet ( ) ; if ( _done == 0 ) { runMoreOnKeyQueueOrStop ( _event . getKey ( ) ) ; } } } ; executor . execute ( r ) ; } }
Pass on runnables to the executor for all listeners . After each event is handled within the listener we check whether the event is processed by all listeners by decrementing a countdown . In case the event is processed completely we check whether more is queued up for this key meanwhile .
30,211
void runMoreOnKeyQueueOrStop ( K key ) { EntryEvent < K , V > _event ; synchronized ( getLockObject ( key ) ) { Queue < EntryEvent < K , V > > q = keyQueue . get ( key ) ; if ( q . isEmpty ( ) ) { keyQueue . remove ( key ) ; return ; } _event = q . remove ( ) ; } List < Listener < K , V > > _listeners = new ArrayList < Listener < K , V > > ( asyncListenerByType . get ( _event . getEventType ( ) ) ) ; if ( _listeners . isEmpty ( ) ) { runMoreOnKeyQueueOrStop ( key ) ; return ; } runAllListenersInParallel ( _event , _listeners ) ; }
Check the event queue for this key and process the next event . If no more events are present remove the queue .
30,212
private long calculateWeight ( final Entry e , final Object v ) { long _weight ; if ( v instanceof ExceptionWrapper ) { _weight = 1 ; } else { _weight = weigher . weigh ( e . getKey ( ) , v ) ; } if ( _weight < 0 ) { throw new IllegalArgumentException ( "weight must be positive." ) ; } return _weight ; }
Exceptions have the minimum weight .
30,213
public void updateWeight ( final Entry e ) { if ( ! isWeigherPresent ( ) ) { return ; } Entry [ ] _evictionChunk = null ; synchronized ( lock ) { updateWeightInLock ( e ) ; _evictionChunk = fillEvictionChunk ( ) ; } evictChunk ( _evictionChunk ) ; int _processCount = 1 ; while ( isEvictionNeeded ( ) && _processCount > 0 ) { synchronized ( lock ) { _evictionChunk = fillEvictionChunk ( ) ; } _processCount = evictChunk ( _evictionChunk ) ; } }
Update the weight in the entry and update the weight calculation in this eviction segment . Since the weight limit might be reached try to evict until within limits again .
30,214
Entry [ ] reuseChunkArray ( ) { Entry [ ] ea = evictChunkReuse ; if ( ea != null ) { evictChunkReuse = null ; } else { ea = new Entry [ chunkSize ] ; } return ea ; }
Safe GC overhead by reusing the chunk array .
30,215
@ SuppressWarnings ( "unchecked" ) private void configureViaSettersDirect ( HeapCache < K , V > c ) { if ( config . getLoader ( ) != null ) { Object obj = c . createCustomization ( config . getLoader ( ) ) ; if ( obj instanceof CacheLoader ) { final CacheLoader < K , V > _loader = ( CacheLoader ) obj ; c . setAdvancedLoader ( new AdvancedCacheLoader < K , V > ( ) { public V load ( final K key , final long currentTime , final CacheEntry < K , V > currentEntry ) throws Exception { return _loader . load ( key ) ; } } ) ; } else { final FunctionalCacheLoader < K , V > _loader = ( FunctionalCacheLoader ) obj ; c . setAdvancedLoader ( new AdvancedCacheLoader < K , V > ( ) { public V load ( final K key , final long currentTime , final CacheEntry < K , V > currentEntry ) throws Exception { return _loader . load ( key ) ; } } ) ; } } if ( config . getAdvancedLoader ( ) != null ) { final AdvancedCacheLoader < K , V > _loader = c . createCustomization ( config . getAdvancedLoader ( ) ) ; AdvancedCacheLoader < K , V > _wrappedLoader = new WrappedAdvancedCacheLoader < K , V > ( c , _loader ) ; c . setAdvancedLoader ( _wrappedLoader ) ; } if ( config . getExceptionPropagator ( ) != null ) { c . setExceptionPropagator ( c . createCustomization ( config . getExceptionPropagator ( ) ) ) ; } c . setCacheConfig ( config ) ; }
The generic wiring code is not working on android . Explicitly call the wiring methods .
30,216
private Eviction constructEviction ( HeapCache hc , HeapCacheListener l , Cache2kConfiguration config ) { final boolean _strictEviction = config . isStrictEviction ( ) ; final int _availableProcessors = Runtime . getRuntime ( ) . availableProcessors ( ) ; final boolean _boostConcurrency = config . isBoostConcurrency ( ) ; final long _maximumWeight = config . getMaximumWeight ( ) ; long _entryCapacity = config . getEntryCapacity ( ) ; if ( _entryCapacity < 0 && _maximumWeight < 0 ) { _entryCapacity = 2000 ; } final int _segmentCountOverride = HeapCache . TUNABLE . segmentCountOverride ; int _segmentCount = determineSegmentCount ( _strictEviction , _availableProcessors , _boostConcurrency , _entryCapacity , _segmentCountOverride ) ; Eviction [ ] _segments = new Eviction [ _segmentCount ] ; long _maxSize = determineMaxSize ( _entryCapacity , _segmentCount ) ; long _maxWeight = determineMaxWeight ( _maximumWeight , _segmentCount ) ; final Weigher _weigher = ( Weigher ) hc . createCustomization ( config . getWeigher ( ) ) ; for ( int i = 0 ; i < _segments . length ; i ++ ) { Eviction ev = new ClockProPlusEviction ( hc , l , _maxSize , _weigher , _maxWeight ) ; _segments [ i ] = ev ; } if ( _segmentCount == 1 ) { return _segments [ 0 ] ; } return new SegmentedEviction ( _segments ) ; }
Construct segmented or queued eviction . For the moment hard coded . If capacity is at least 1000 we use 2 segments if 2 or more CPUs are available . Segmenting the eviction only improves for lots of concurrent inserts or evictions there is no effect on read performance .
30,217
public void setTitle ( final String TITLE ) { if ( null == title ) { _title = TITLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { title . set ( TITLE ) ; } }
Defines the title of the clock . The title could be used to show for example the current city or timezone
30,218
public void setText ( final String TEXT ) { if ( null == text ) { _text = TEXT ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { text . set ( TEXT ) ; } }
Define the text for the clock . This text could be used for additional information .
30,219
public void setSectionsVisible ( final boolean VISIBLE ) { if ( null == sectionsVisible ) { _sectionsVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { sectionsVisible . set ( VISIBLE ) ; } }
Defines if the sections should be drawn in the clock .
30,220
public void setHighlightSections ( final boolean HIGHLIGHT ) { if ( null == highlightSections ) { _highlightSections = HIGHLIGHT ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { highlightSections . set ( HIGHLIGHT ) ; } }
Defines if sections should be highlighted in case they contain the current time .
30,221
public void setAreas ( final List < TimeSection > AREAS ) { areas . setAll ( AREAS ) ; Collections . sort ( areas , new TimeSectionComparator ( ) ) ; fireUpdateEvent ( SECTION_EVENT ) ; }
Sets the areas to the given list of TimeSection objects . The sections will be used to colorize areas with a special meaning . Areas in the Medusa library usually are more eye - catching than Sections .
30,222
public void addArea ( final TimeSection AREA ) { if ( null == AREA ) return ; areas . add ( AREA ) ; Collections . sort ( areas , new TimeSectionComparator ( ) ) ; fireUpdateEvent ( SECTION_EVENT ) ; }
Adds the given TimeSection to the list of areas . Areas in the Medusa library usually are more eye - catching than Sections .
30,223
public void removeArea ( final TimeSection AREA ) { if ( null == AREA ) return ; areas . remove ( AREA ) ; Collections . sort ( areas , new TimeSectionComparator ( ) ) ; fireUpdateEvent ( SECTION_EVENT ) ; }
Removes the given TimeSection from the list of areas . Areas in the Medusa library usually are more eye - catching than Sections .
30,224
public void setAreasVisible ( final boolean VISIBLE ) { if ( null == areasVisible ) { _areasVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { areasVisible . set ( VISIBLE ) ; } }
Defines if the areas should be drawn in the clock .
30,225
public void setHighlightAreas ( final boolean HIGHLIGHT ) { if ( null == highlightAreas ) { _highlightAreas = HIGHLIGHT ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { highlightAreas . set ( HIGHLIGHT ) ; } }
Defines if areas should be highlighted in case they contain the current time .
30,226
public void setTitleVisible ( final boolean VISIBLE ) { if ( null == titleVisible ) { _titleVisible = VISIBLE ; fireUpdateEvent ( VISIBILITY_EVENT ) ; } else { titleVisible . set ( VISIBLE ) ; } }
Defines if the title of the clock will be drawn .
30,227
public void setBackgroundPaint ( final Paint PAINT ) { if ( null == backgroundPaint ) { _backgroundPaint = PAINT ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { backgroundPaint . set ( PAINT ) ; } }
Defines the Paint object that will be used to fill the clock background . This is usally a Color object .
30,228
public void setBorderPaint ( final Paint PAINT ) { if ( null == borderPaint ) { _borderPaint = PAINT ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { borderPaint . set ( PAINT ) ; } }
Defines the Paint object that will be used to draw the border of the clock . Usually this is a Color object .
30,229
public void setBorderWidth ( final double WIDTH ) { if ( null == borderWidth ) { _borderWidth = Helper . clamp ( 0.0 , 50.0 , WIDTH ) ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { borderWidth . set ( WIDTH ) ; } }
Defines the width in pixels that will be used to draw the border of the clock . The value will be clamped between 0 and 50 pixels .
30,230
public void setForegroundPaint ( final Paint PAINT ) { if ( null == foregroundPaint ) { _foregroundPaint = PAINT ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { foregroundPaint . set ( PAINT ) ; } }
Defines the Paint object that will be used to fill the foreground of the clock . This could be used to visualize glass effects etc . and is only rarely used .
30,231
public void setTitleColor ( final Color COLOR ) { if ( null == titleColor ) { _titleColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { titleColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the title of the clock
30,232
public void setTextColor ( final Color COLOR ) { if ( null == textColor ) { _textColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { textColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the text of the clock .
30,233
public void setDateColor ( final Color COLOR ) { if ( null == dateColor ) { _dateColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { dateColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the date of the clock
30,234
public void setMinuteTickMarkColor ( final Color COLOR ) { if ( null == minuteTickMarkColor ) { _minuteTickMarkColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { minuteTickMarkColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the minute tickmarks of the clock .
30,235
public void setTickLabelColor ( final Color COLOR ) { if ( null == tickLabelColor ) { _tickLabelColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { tickLabelColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the ticklabels of the clock .
30,236
public void setTickLabelsVisible ( final boolean VISIBLE ) { if ( null == tickLabelsVisible ) { _tickLabelsVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { tickLabelsVisible . set ( VISIBLE ) ; } }
Defines if the ticklabels will be drawn .
30,237
public void setSecondColor ( final Color COLOR ) { if ( null == secondColor ) { _secondColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { secondColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the second hand of the clock
30,238
public void setLcdCrystalEnabled ( final boolean ENABLED ) { if ( null == lcdCrystalEnabled ) { _lcdCrystalEnabled = ENABLED ; fireUpdateEvent ( VISIBILITY_EVENT ) ; } else { lcdCrystalEnabled . set ( ENABLED ) ; } }
Defines if the crystal effect of the LCD display will be drawn . This feature could decrease the performance if you run it on embedded devices because it will calculate a bitmap image where each pixel will be calculated .
30,239
public void setShadowsEnabled ( final boolean ENABLED ) { if ( null == shadowsEnabled ) { _shadowsEnabled = ENABLED ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { shadowsEnabled . set ( ENABLED ) ; } }
Defines if effects like shadows will be drawn .
30,240
public void setLocale ( final Locale LOCALE ) { if ( null == locale ) { _locale = LOCALE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { locale . set ( LOCALE ) ; } }
Defines the Locale that will be used to format the date in some ClockSkins .
30,241
public void setCustomFont ( final Font FONT ) { if ( null == customFont ) { _customFont = FONT ; fireUpdateEvent ( RESIZE_EVENT ) ; } else { customFont . set ( FONT ) ; } }
Defines the custom font that can be used to render all text elements . To enable the custom font one has to set customFontEnabled = true
30,242
private void checkAlarms ( final ZonedDateTime TIME ) { alarmsToRemove . clear ( ) ; for ( Alarm alarm : alarms ) { final ZonedDateTime ALARM_TIME = alarm . getTime ( ) ; switch ( alarm . getRepetition ( ) ) { case ONCE : if ( TIME . isAfter ( ALARM_TIME ) ) { if ( alarm . isArmed ( ) ) { fireAlarmEvent ( new AlarmEvent ( Clock . this , alarm ) ) ; alarm . executeCommand ( ) ; } alarmsToRemove . add ( alarm ) ; } break ; case HALF_HOURLY : if ( ( ALARM_TIME . getMinute ( ) == TIME . getMinute ( ) || ALARM_TIME . plusMinutes ( 30 ) . getMinute ( ) == TIME . getMinute ( ) ) && ALARM_TIME . getSecond ( ) == TIME . getSecond ( ) ) { if ( alarm . isArmed ( ) ) { fireAlarmEvent ( new AlarmEvent ( Clock . this , alarm ) ) ; alarm . executeCommand ( ) ; } } break ; case HOURLY : if ( ALARM_TIME . getMinute ( ) == TIME . getMinute ( ) && ALARM_TIME . getSecond ( ) == TIME . getSecond ( ) ) { if ( alarm . isArmed ( ) ) { fireAlarmEvent ( new AlarmEvent ( Clock . this , alarm ) ) ; alarm . executeCommand ( ) ; } } break ; case DAILY : if ( ALARM_TIME . getHour ( ) == TIME . getHour ( ) && ALARM_TIME . getMinute ( ) == TIME . getMinute ( ) && ALARM_TIME . getSecond ( ) == TIME . getSecond ( ) ) { if ( alarm . isArmed ( ) ) { fireAlarmEvent ( new AlarmEvent ( Clock . this , alarm ) ) ; alarm . executeCommand ( ) ; } } break ; case WEEKLY : if ( ALARM_TIME . getDayOfWeek ( ) == TIME . getDayOfWeek ( ) && ALARM_TIME . getHour ( ) == TIME . getHour ( ) && ALARM_TIME . getMinute ( ) == TIME . getMinute ( ) && ALARM_TIME . getSecond ( ) == TIME . getSecond ( ) ) { if ( alarm . isArmed ( ) ) { fireAlarmEvent ( new AlarmEvent ( Clock . this , alarm ) ) ; alarm . executeCommand ( ) ; } } break ; } } for ( Alarm alarm : alarmsToRemove ) { removeAlarm ( alarm ) ; } }
Calling this method will check the current time against all Alarm objects in alarms . The Alarm object will fire events in case the time is after the alarm time .
30,243
public void setMinValue ( final double VALUE ) { if ( Status . RUNNING == timeline . getStatus ( ) ) { timeline . jumpTo ( Duration . ONE ) ; } if ( null == minValue ) { if ( VALUE > getMaxValue ( ) ) { setMaxValue ( VALUE ) ; } _minValue = Helper . clamp ( - Double . MAX_VALUE , getMaxValue ( ) , VALUE ) ; setRange ( getMaxValue ( ) - _minValue ) ; if ( Double . compare ( originalMinValue , - Double . MAX_VALUE ) == 0 ) originalMinValue = _minValue ; if ( isStartFromZero ( ) && _minValue < 0 ) setValue ( 0 ) ; if ( Double . compare ( originalThreshold , getThreshold ( ) ) < 0 ) { setThreshold ( Helper . clamp ( _minValue , getMaxValue ( ) , originalThreshold ) ) ; } updateFormatString ( ) ; fireUpdateEvent ( RECALC_EVENT ) ; if ( ! valueProperty ( ) . isBound ( ) ) Gauge . this . setValue ( Helper . clamp ( getMinValue ( ) , getMaxValue ( ) , Gauge . this . getValue ( ) ) ) ; } else { minValue . set ( VALUE ) ; } }
Sets the minimum value of the gauge scale to the given value
30,244
public void setSubTitle ( final String SUBTITLE ) { if ( null == subTitle ) { _subTitle = SUBTITLE ; fireUpdateEvent ( VISIBILITY_EVENT ) ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { subTitle . set ( SUBTITLE ) ; } }
Sets the subtitle of the gauge . This subtitle will usually only be visible if it is not empty .
30,245
public void setAreas ( final List < Section > AREAS ) { areas . setAll ( AREAS ) ; Collections . sort ( areas , new SectionComparator ( ) ) ; fireUpdateEvent ( SECTION_EVENT ) ; }
Sets the sections to the given list of Section objects . The sections will be used to colorize areas with a special meaning such as the red area in a rpm gauge . Areas in the Medusa library usually are more eye - catching than Sections .
30,246
public void addArea ( final Section AREA ) { if ( null == AREA ) return ; areas . add ( AREA ) ; Collections . sort ( areas , new SectionComparator ( ) ) ; fireUpdateEvent ( SECTION_EVENT ) ; }
Adds the given Section to the list of areas . Areas in the Medusa library usually are more eye - catching than Sections .
30,247
public void removeArea ( final Section AREA ) { if ( null == AREA ) return ; areas . remove ( AREA ) ; Collections . sort ( areas , new SectionComparator ( ) ) ; fireUpdateEvent ( SECTION_EVENT ) ; }
Removes the given Section from the list of areas . Areas in the Medusa library usually are more eye - catching than Sections .
30,248
public void setTickMarkSections ( final List < Section > SECTIONS ) { tickMarkSections . setAll ( SECTIONS ) ; Collections . sort ( tickMarkSections , new SectionComparator ( ) ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Sets the tickmark sections to the given list of Section objects .
30,249
public void addTickMarkSection ( final Section SECTION ) { if ( null == SECTION ) return ; tickMarkSections . add ( SECTION ) ; Collections . sort ( tickMarkSections , new SectionComparator ( ) ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Adds the given Section to the list of tickmark sections .
30,250
public void removeTickMarkSection ( final Section SECTION ) { if ( null == SECTION ) return ; tickMarkSections . remove ( SECTION ) ; Collections . sort ( tickMarkSections , new SectionComparator ( ) ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Removes the given Section from the list of tickmark sections .
30,251
public void setTickLabelSections ( final List < Section > SECTIONS ) { tickLabelSections . setAll ( SECTIONS ) ; Collections . sort ( tickLabelSections , new SectionComparator ( ) ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Sets the ticklabel sections to the given list of Section objects .
30,252
public void addTickLabelSection ( final Section SECTION ) { if ( null == SECTION ) return ; tickLabelSections . add ( SECTION ) ; Collections . sort ( tickLabelSections , new SectionComparator ( ) ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Adds the given Section to the list of ticklabel sections .
30,253
public void removeTickLabelSection ( final Section SECTION ) { if ( null == SECTION ) return ; tickLabelSections . remove ( SECTION ) ; Collections . sort ( tickLabelSections , new SectionComparator ( ) ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Removes the given Section from the list of ticklabel sections .
30,254
public void addMarker ( final Marker MARKER ) { if ( null == MARKER ) return ; markers . add ( MARKER ) ; Collections . sort ( markers , new MarkerComparator ( ) ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Adds the given Marker to the list of markers .
30,255
public void removeMarker ( final Marker MARKER ) { if ( null == MARKER ) return ; markers . remove ( MARKER ) ; Collections . sort ( markers , new MarkerComparator ( ) ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Removes the given Marker from the list of markers .
30,256
public void setForegroundBaseColor ( final Color COLOR ) { if ( null == titleColor ) { _titleColor = COLOR ; } else { titleColor . set ( COLOR ) ; } if ( null == subTitleColor ) { _subTitleColor = COLOR ; } else { subTitleColor . set ( COLOR ) ; } if ( null == unitColor ) { _unitColor = COLOR ; } else { unitColor . set ( COLOR ) ; } if ( null == valueColor ) { _valueColor = COLOR ; } else { valueColor . set ( COLOR ) ; } if ( null == tickLabelColor ) { _tickLabelColor = COLOR ; } else { tickLabelColor . set ( COLOR ) ; } if ( null == zeroColor ) { _zeroColor = COLOR ; } else { zeroColor . set ( COLOR ) ; } if ( null == tickMarkColor ) { _tickMarkColor = COLOR ; } else { tickMarkColor . set ( COLOR ) ; } if ( null == majorTickMarkColor ) { _majorTickMarkColor = COLOR ; } else { majorTickMarkColor . set ( COLOR ) ; } if ( null == mediumTickMarkColor ) { _mediumTickMarkColor = COLOR ; } else { mediumTickMarkColor . set ( COLOR ) ; } if ( null == minorTickMarkColor ) { _minorTickMarkColor = COLOR ; } else { minorTickMarkColor . set ( COLOR ) ; } fireUpdateEvent ( REDRAW_EVENT ) ; }
A convenient method to set the color of foreground elements like title subTitle unit value tickLabel and tickMark to the given Color .
30,257
public void setZeroColor ( final Color COLOR ) { if ( null == zeroColor ) { _zeroColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { zeroColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the 0 tickmark and ticklabel when the gauge range has a negative min - and positive maxValue .
30,258
public void setKnobType ( final KnobType TYPE ) { if ( null == knobType ) { _knobType = null == TYPE ? KnobType . STANDARD : TYPE ; fireUpdateEvent ( RESIZE_EVENT ) ; } else { knobType . set ( TYPE ) ; } }
Defines the type of knob that will be used in the radial gauges . The values are STANDARD PLAIN METAL and FLAT .
30,259
public void setKnobVisible ( final boolean VISIBLE ) { if ( null == knobVisible ) { _knobVisible = VISIBLE ; fireUpdateEvent ( VISIBILITY_EVENT ) ; } else { knobVisible . set ( VISIBLE ) ; } }
Defines if the knob is visible .
30,260
public void setAngleRange ( final double RANGE ) { double tmpAngleRange = Helper . clamp ( 0.0 , 360.0 , RANGE ) ; if ( null == angleRange ) { _angleRange = tmpAngleRange ; setAngleStep ( tmpAngleRange / getRange ( ) ) ; if ( isAutoScale ( ) ) { calcAutoScale ( ) ; } fireUpdateEvent ( RECALC_EVENT ) ; } else { angleRange . set ( tmpAngleRange ) ; } }
Defines the angle range in degree that will be used to draw the scale of the radial gauge . The given range will be clamped in the range of 0 - 360 degrees . The range will start at the startAngle and will be drawn in the direction dependent on the scaleDirection .
30,261
public void setBarEffectEnabled ( final boolean ENABLED ) { if ( null == barEffectEnabled ) { _barEffectEnabled = ENABLED ; fireUpdateEvent ( VISIBILITY_EVENT ) ; } else { barEffectEnabled . set ( ENABLED ) ; } }
Defines if the the highlight effect on the gauges like the LinearSkin bar will be drawn . If you would like to have a more flat style you should set this to false .
30,262
public void setScaleDirection ( final ScaleDirection DIRECTION ) { if ( null == scaleDirection ) { _scaleDirection = null == DIRECTION ? ScaleDirection . CLOCKWISE : DIRECTION ; fireUpdateEvent ( RECALC_EVENT ) ; } else { scaleDirection . set ( DIRECTION ) ; } }
Defines the direction of the scale . The values are CLOCKWISE and COUNTER_CLOCKWISE . This property is needed to realize gauges like in QuarterSkin where the needle and knob should be placed on the upper right corner and the scale should start at the bottom . Here you need a counter - clockwise direction of the scale .
30,263
public void setTickLabelOrientation ( final TickLabelOrientation ORIENTATION ) { if ( null == tickLabelOrientation ) { _tickLabelOrientation = null == ORIENTATION ? TickLabelOrientation . HORIZONTAL : ORIENTATION ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { tickLabelOrientation . set ( ORIENTATION ) ; } }
Defines the orientation of the ticklabels . The values are HORIZONTAL ORTHOGONAL and TANGENT . Especially the ORTHOGONAL setting can be useful when using scales with big numbers .
30,264
public void setTickMarkColor ( final Color COLOR ) { if ( null == tickMarkColor ) { _tickMarkColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { tickMarkColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the tickmarks . This color will only be used if no tickmark section or major - medium - and minorTickMarkColor is defined at the position of the tickmark .
30,265
public void setMajorTickMarkColor ( final Color COLOR ) { if ( null == majorTickMarkColor ) { _majorTickMarkColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { majorTickMarkColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the major tickmarks . This color will only be used if no tickmark section is defined at the position of the tickmark .
30,266
public void setMajorTickMarkLengthFactor ( final double FACTOR ) { if ( null == majorTickMarkLengthFactor ) { _majorTickMarkLengthFactor = Helper . clamp ( 0.0 , 1.0 , FACTOR ) ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { majorTickMarkLengthFactor . set ( FACTOR ) ; } }
The factor defines the length of the major tick mark . It can be in the range from 0 - 1 .
30,267
public void setMajorTickMarkWidthFactor ( final double FACTOR ) { if ( null == majorTickMarkWidthFactor ) { _majorTickMarkWidthFactor = Helper . clamp ( 0.0 , 1.0 , FACTOR ) ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { majorTickMarkWidthFactor . set ( FACTOR ) ; } }
The factor defines the width of the major tick mark . It can be in the range from 0 - 1 .
30,268
public void setMediumTickMarkColor ( final Color COLOR ) { if ( null == mediumTickMarkColor ) { _mediumTickMarkColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { mediumTickMarkColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the medium tickmarks . This color will only be used if no tickmark section is defined at the position of the tickmark .
30,269
public void setMediumTickMarkLengthFactor ( final double FACTOR ) { if ( null == mediumTickMarkLengthFactor ) { _mediumTickMarkLengthFactor = Helper . clamp ( 0.0 , 1.0 , FACTOR ) ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { mediumTickMarkLengthFactor . set ( FACTOR ) ; } }
The factor defines the length of the medium tick mark . It can be in the range from 0 - 1 .
30,270
public void setMediumTickMarkWidthFactor ( final double FACTOR ) { if ( null == mediumTickMarkWidthFactor ) { _mediumTickMarkWidthFactor = Helper . clamp ( 0.0 , 1.0 , FACTOR ) ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { mediumTickMarkWidthFactor . set ( FACTOR ) ; } }
The factor defines the width of the medium tick mark . It can be in the range from 0 - 1 .
30,271
public void setMinorTickMarkColor ( final Color COLOR ) { if ( null == minorTickMarkColor ) { _minorTickMarkColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { minorTickMarkColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the minor tickmarks . This color will only be used if no tickmark section is defined at the position of the tickmark .
30,272
public void setMinorTickMarkLengthFactor ( final double FACTOR ) { if ( null == minorTickMarkLengthFactor ) { _minorTickMarkLengthFactor = Helper . clamp ( 0.0 , 1.0 , FACTOR ) ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { minorTickMarkLengthFactor . set ( FACTOR ) ; } }
The factor defines the length of the minor tick mark . It can be in the range from 0 - 1 .
30,273
public void setMinorTickMarkWidthFactor ( final double FACTOR ) { if ( null == minorTickMarkWidthFactor ) { _minorTickMarkWidthFactor = Helper . clamp ( 0.0 , 1.0 , FACTOR ) ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { minorTickMarkWidthFactor . set ( FACTOR ) ; } }
The factor defines the width of the minor tick mark . It can be in the range from 0 - 1 .
30,274
public void setMajorTickMarkType ( final TickMarkType TYPE ) { if ( null == majorTickMarkType ) { _majorTickMarkType = null == TYPE ? TickMarkType . LINE : TYPE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { majorTickMarkType . set ( TYPE ) ; } }
Defines the shape that will be used to visualize the major tickmark . Values are LINE DOT TRAPEZOID BOX TICK_LABEL and PILL
30,275
public void setMediumTickMarkType ( final TickMarkType TYPE ) { if ( null == mediumTickMarkType ) { _mediumTickMarkType = null == TYPE ? TickMarkType . LINE : TYPE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { mediumTickMarkType . set ( TYPE ) ; } }
Defines the shape that will be used to visualize the medium tickmark . Values are LINE DOT TRAPEZOID BOX and PILL
30,276
public void setMinorTickMarkType ( final TickMarkType TYPE ) { if ( null == minorTickMarkType ) { _minorTickMarkType = null == TYPE ? TickMarkType . LINE : TYPE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { minorTickMarkType . set ( TYPE ) ; } }
Defines the shape that will be used to visualize the minor tickmark . Values are LINE DOT TRAPEZOID BOX and PILL
30,277
public void setNeedleSize ( final NeedleSize SIZE ) { if ( null == needleSize ) { _needleSize = null == SIZE ? NeedleSize . STANDARD : SIZE ; fireUpdateEvent ( RESIZE_EVENT ) ; } else { needleSize . set ( SIZE ) ; } }
Defines the thickness of the needle . The values are THIN STANDARD and THICK
30,278
public void setNeedleBehavior ( final NeedleBehavior BEHAVIOR ) { if ( null == needleBehavior ) { _needleBehavior = null == BEHAVIOR ? NeedleBehavior . STANDARD : BEHAVIOR ; } else { needleBehavior . set ( BEHAVIOR ) ; } }
Defines the behavior of the needle movement . The values are STANDARD and OPTIMIZED This is an experimental feature that only makes sense in gauges that use an angleRange of 360 degrees and where the needle should be able to use the shortest way to the target value . As an example one can think of a compass . If the value in a compass changes from 20 degrees to 290 degrees the needle will take the shortest way to the value in this case this means it will rotate counter - clockwise .
30,279
public void setNeedleColor ( final Color COLOR ) { if ( null == needleColor ) { _needleColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { needleColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the needle of the radial gauges .
30,280
public void setNeedleBorderColor ( final Color COLOR ) { if ( null == needleBorderColor ) { _needleBorderColor = null == COLOR ? Color . TRANSPARENT : COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { needleBorderColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the border of the needle .
30,281
public void setBarBorderColor ( final Color COLOR ) { if ( null == barBorderColor ) { _barBorderColor = null == COLOR ? Color . TRANSPARENT : COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { barBorderColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the border of the bar .
30,282
public void setLcdFont ( final LcdFont FONT ) { if ( null == lcdFont ) { _lcdFont = null == FONT ? LcdFont . DIGITAL_BOLD : FONT ; fireUpdateEvent ( RESIZE_EVENT ) ; } else { lcdFont . set ( FONT ) ; } }
Defines the font that will be used to visualize the LCD value if the gauge has a LCD display . The values are STANDARD LCD SLIM DIGITAL_BOLD ELEKTRA
30,283
public void setLedColor ( final Color COLOR ) { if ( null == ledColor ) { _ledColor = null == COLOR ? Color . RED : COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { ledColor . set ( COLOR ) ; } }
Defines the color that will be used to visualize the LED of the gauge if it has one .
30,284
public void setSubTitleColor ( final Color COLOR ) { if ( null == subTitleColor ) { _subTitleColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { subTitleColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the subTitle of the gauge .
30,285
public void setAverageColor ( final Color COLOR ) { if ( null == averageColor ) { _averageColor = COLOR ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { averageColor . set ( COLOR ) ; } }
Defines the color that will be used to colorize the average indicator of the gauge .
30,286
public void setAreaTextVisible ( final boolean VISIBLE ) { if ( null == areaTextVisible ) { _areaTextVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { areaTextVisible . set ( VISIBLE ) ; } }
Defines if the text of the areas should be drawn inside the areas .
30,287
public void setAreaIconsVisible ( final boolean VISIBLE ) { if ( null == areaIconsVisible ) { _areaIconsVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { areaIconsVisible . set ( VISIBLE ) ; } }
Defines if the icon of the areas should be drawn inside the areas .
30,288
public void setTickMarkSectionsVisible ( final boolean VISIBLE ) { if ( null == tickMarkSectionsVisible ) { _tickMarkSectionsVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { tickMarkSectionsVisible . set ( VISIBLE ) ; } }
Defines if the tickmark sections should be used to colorize the tickmarks .
30,289
public void setTickLabelSectionsVisible ( final boolean VISIBLE ) { if ( null == tickLabelSectionsVisible ) { _tickLabelSectionsVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { tickLabelSectionsVisible . set ( VISIBLE ) ; } }
Defines if the ticklabel sections should be used to colorize the ticklabels .
30,290
public void setMarkersVisible ( final boolean VISIBLE ) { if ( null == markersVisible ) { _markersVisible = VISIBLE ; fireUpdateEvent ( VISIBILITY_EVENT ) ; } else { markersVisible . set ( VISIBLE ) ; } }
Defines if the markers should be drawn
30,291
public void setOnlyFirstAndLastTickLabelVisible ( final boolean VISIBLE ) { if ( null == onlyFirstAndLastTickLabelVisible ) { _onlyFirstAndLastTickLabelVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { onlyFirstAndLastTickLabelVisible . set ( VISIBLE ) ; } }
Defines if only the first and the last ticklabel will be drawn . Sometimes this could be useful if a gauge should for example only should show 0 and 1000 .
30,292
public void setMajorTickMarksVisible ( final boolean VISIBLE ) { if ( null == majorTickMarksVisible ) { _majorTickMarksVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { majorTickMarksVisible . set ( VISIBLE ) ; } }
Defines if the major tickmarks should be drawn If set to false and minorTickmarks == true a minor tickmark will be drawn instead of the major tickmark .
30,293
public void setMinorTickMarksVisible ( final boolean VISIBLE ) { if ( null == minorTickMarksVisible ) { _minorTickMarksVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { minorTickMarksVisible . set ( VISIBLE ) ; } }
Defines if the minor tickmarks should be drawn
30,294
public void setTickMarkRingVisible ( final boolean VISIBLE ) { if ( null == tickMarkRingVisible ) { _tickMarkRingVisible = VISIBLE ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { tickMarkRingVisible . set ( VISIBLE ) ; } }
Defines if an additional ring should be drawn that connects the tick marks .
30,295
public void setOrientation ( final Orientation ORIENTATION ) { if ( null == orientation ) { _orientation = ORIENTATION ; fireUpdateEvent ( RESIZE_EVENT ) ; } else { orientation . set ( ORIENTATION ) ; } }
Defines the orientation of the control . This feature will only be used in the BulletChartSkin and LinearSkin . Values are HORIZONTAL and VERTICAL
30,296
public void setCustomTickLabelsEnabled ( final boolean ENABLED ) { if ( null == customTickLabelsEnabled ) { _customTickLabelsEnabled = ENABLED ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { customTickLabelsEnabled . set ( ENABLED ) ; } }
Defines if custom ticklabels should be used instead of the automatically calculated ones . This could be useful for gauges like a compass where you need N E S and W instead of numbers .
30,297
public void addCustomTickLabel ( final String TICK_LABEL ) { if ( null == TICK_LABEL ) return ; if ( ! customTickLabels . contains ( TICK_LABEL ) ) customTickLabels . add ( TICK_LABEL ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Adds the given String to the list of custom ticklabels
30,298
public void removeCustomTickLabel ( final String TICK_LABEL ) { if ( null == TICK_LABEL ) return ; if ( customTickLabels . contains ( TICK_LABEL ) ) customTickLabels . remove ( TICK_LABEL ) ; fireUpdateEvent ( REDRAW_EVENT ) ; }
Removes the given String from the list of custom ticklabels
30,299
public void setCustomTickLabelFontSize ( final double SIZE ) { if ( null == customTickLabelFontSize ) { _customTickLabelFontSize = Helper . clamp ( 0.0 , 72.0 , SIZE ) ; fireUpdateEvent ( REDRAW_EVENT ) ; } else { customTickLabelFontSize . set ( SIZE ) ; } }
Defines the custom font size . The default font size is 18px at a size of 250px . This value will be used to calculate the current font size for the ticklabels when scaling .