idx
int64 0
41.2k
| question
stringlengths 73
5.81k
| target
stringlengths 5
918
|
|---|---|---|
40,200
|
private String applyPattern ( String key , Object [ ] messageArguments ) { String message = getString ( key ) ; String output = MessageFormat . format ( message , messageArguments ) ; return output ; }
|
Helper function that applies the messageArguments to a message from the resource object
|
40,201
|
private synchronized void logEvent ( int level , String string , Throwable throwable ) { if ( level > _loggingLevel ) { return ; } if ( _logFile != null ) { PrintWriter pw = null ; try { pw = new PrintWriter ( new FileWriter ( _logFile , true ) ) ; pw . println ( _servletName + "(" + level + "): " + string ) ; if ( throwable != null ) { throwable . printStackTrace ( pw ) ; } pw . close ( ) ; return ; } catch ( IOException ioe ) { } } if ( throwable == null ) { _servletContext . log ( string ) ; } else { _servletContext . log ( string , throwable ) ; } }
|
The method that actually does the logging
|
40,202
|
public boolean artifactContainsClass ( Artifact artifact , final String mainClass ) throws MojoExecutionException { boolean containsClass = true ; URL url ; try { url = artifact . getFile ( ) . toURI ( ) . toURL ( ) ; } catch ( MalformedURLException e ) { throw new MojoExecutionException ( "Could not get artifact url: " + artifact . getFile ( ) , e ) ; } ClassLoader cl = new java . net . URLClassLoader ( new URL [ ] { url } ) ; Class < ? > c = null ; try { c = Class . forName ( mainClass , false , cl ) ; } catch ( ClassNotFoundException e ) { getLogger ( ) . debug ( "artifact " + artifact + " doesn't contain the main class: " + mainClass ) ; containsClass = false ; } catch ( Throwable t ) { getLogger ( ) . info ( "artifact " + artifact + " seems to contain the main class: " + mainClass + " but the jar doesn't seem to contain all dependencies " + t . getMessage ( ) ) ; } if ( c != null ) { getLogger ( ) . debug ( "Checking if the loaded class contains a main method." ) ; try { c . getMethod ( "main" , String [ ] . class ) ; } catch ( NoSuchMethodException e ) { getLogger ( ) . warn ( "The specified main class (" + mainClass + ") doesn't seem to contain a main method... " + "Please check your configuration." + e . getMessage ( ) ) ; } catch ( NoClassDefFoundError e ) { getLogger ( ) . warn ( "Something failed while checking if the main class contains the main() method. " + "This is probably due to the limited classpath we have provided to the class loader. " + "The specified main class (" + mainClass + ") found in the jar is *assumed* to contain a main method... " + e . getMessage ( ) ) ; } catch ( Throwable t ) { getLogger ( ) . error ( "Unknown error: Couldn't check if the main class has a main method. " + "The specified main class (" + mainClass + ") found in the jar is *assumed* to contain a main method..." , t ) ; } } return containsClass ; }
|
Tests if the given fully qualified name exists in the given artifact .
|
40,203
|
public static void main ( String [ ] args ) throws IOException { boolean diff = true ; boolean minimal = true ; String outputFile = "out.jardiff" ; for ( int counter = 0 ; counter < args . length ; counter ++ ) { if ( args [ counter ] . equals ( "-nonminimal" ) || args [ counter ] . equals ( "-n" ) ) { minimal = false ; } else if ( args [ counter ] . equals ( "-creatediff" ) || args [ counter ] . equals ( "-c" ) ) { diff = true ; } else if ( args [ counter ] . equals ( "-applydiff" ) || args [ counter ] . equals ( "-a" ) ) { diff = false ; } else if ( args [ counter ] . equals ( "-debug" ) || args [ counter ] . equals ( "-d" ) ) { _debug = true ; } else if ( args [ counter ] . equals ( "-output" ) || args [ counter ] . equals ( "-o" ) ) { if ( ++ counter < args . length ) { outputFile = args [ counter ] ; } } else if ( args [ counter ] . equals ( "-applydiff" ) || args [ counter ] . equals ( "-a" ) ) { diff = false ; } else { if ( ( counter + 2 ) != args . length ) { showHelp ( ) ; System . exit ( 0 ) ; } if ( diff ) { try { OutputStream os = new FileOutputStream ( outputFile ) ; JarDiff . createPatch ( args [ counter ] , args [ counter + 1 ] , os , minimal ) ; os . close ( ) ; } catch ( IOException ioe ) { try { System . out . println ( getResources ( ) . getString ( "jardiff.error.create" ) + " " + ioe ) ; } catch ( MissingResourceException mre ) { } } } else { try { OutputStream os = new FileOutputStream ( outputFile ) ; new JarDiffPatcher ( ) . applyPatch ( null , args [ counter ] , args [ counter + 1 ] , os ) ; os . close ( ) ; } catch ( IOException ioe ) { try { System . out . println ( getResources ( ) . getString ( "jardiff.error.apply" ) + " " + ioe ) ; } catch ( MissingResourceException mre ) { } } } System . exit ( 0 ) ; } } showHelp ( ) ; }
|
- creatediff - applydiff - debug - output file
|
40,204
|
private void processDependencies ( ) throws MojoExecutionException { processDependency ( getProject ( ) . getArtifact ( ) ) ; AndArtifactFilter filter = new AndArtifactFilter ( ) ; if ( dependencies != null && dependencies . getIncludes ( ) != null && ! dependencies . getIncludes ( ) . isEmpty ( ) ) { filter . add ( new IncludesArtifactFilter ( dependencies . getIncludes ( ) ) ) ; } if ( dependencies != null && dependencies . getExcludes ( ) != null && ! dependencies . getExcludes ( ) . isEmpty ( ) ) { filter . add ( new ExcludesArtifactFilter ( dependencies . getExcludes ( ) ) ) ; } Collection < Artifact > artifacts = isExcludeTransitive ( ) ? getProject ( ) . getDependencyArtifacts ( ) : getProject ( ) . getArtifacts ( ) ; for ( Artifact artifact : artifacts ) { if ( filter . include ( artifact ) ) { processDependency ( artifact ) ; } } }
|
Iterate through all the top level and transitive dependencies declared in the project and collect all the runtime scope dependencies for inclusion in the . zip and signing .
|
40,205
|
protected File getResourcesDirectory ( ) { if ( resourcesDirectory == null ) { resourcesDirectory = new File ( getProject ( ) . getBasedir ( ) , DEFAULT_RESOURCES_DIR ) ; } return resourcesDirectory ; }
|
Returns the location of the directory containing non - jar resources that are to be included in the JNLP bundle .
|
40,206
|
protected void signOrRenameJars ( ) throws MojoExecutionException { if ( sign != null ) { try { ClassLoader loader = getCompileClassLoader ( ) ; sign . init ( getWorkDirectory ( ) , getLog ( ) . isDebugEnabled ( ) , signTool , securityDispatcher , loader ) ; } catch ( MalformedURLException e ) { throw new MojoExecutionException ( "Could not create classloader" , e ) ; } if ( unsignAlreadySignedJars ) { removeExistingSignatures ( getLibDirectory ( ) ) ; } if ( isPack200 ( ) ) { unpackJars ( getLibDirectory ( ) ) ; ioUtil . deleteFiles ( getLibDirectory ( ) , unprocessedPack200FileFilter ) ; } if ( MapUtils . isNotEmpty ( updateManifestEntries ) ) { updateManifestEntries ( getLibDirectory ( ) ) ; } int signedJars = signJars ( getLibDirectory ( ) ) ; if ( signedJars != getModifiedJnlpArtifacts ( ) . size ( ) ) { throw new IllegalStateException ( "The number of signed artifacts (" + signedJars + ") differ from the number of modified " + "artifacts (" + getModifiedJnlpArtifacts ( ) . size ( ) + "). Implementation error" ) ; } } else { makeUnprocessedFilesFinal ( getLibDirectory ( ) ) ; } if ( isPack200 ( ) ) { verboseLog ( "-- Pack jars" ) ; pack200Jars ( getLibDirectory ( ) , processedJarFileFilter ) ; } }
|
If sign is enabled sign the jars otherwise rename them into final jars
|
40,207
|
protected void verboseLog ( String msg ) { if ( isVerbose ( ) ) { getLog ( ) . info ( msg ) ; } else { getLog ( ) . debug ( msg ) ; } }
|
Log as info when verbose or info is enabled as debug otherwise .
|
40,208
|
private int removeExistingSignatures ( File workDirectory ) throws MojoExecutionException { getLog ( ) . info ( "-- Remove existing signatures" ) ; File tempDir = new File ( workDirectory , "temp_extracted_jars" ) ; ioUtil . removeDirectory ( tempDir ) ; ioUtil . makeDirectoryIfNecessary ( tempDir ) ; File [ ] jarFiles = workDirectory . listFiles ( unprocessedJarFileFilter ) ; for ( File jarFile : jarFiles ) { if ( isJarSigned ( jarFile ) ) { if ( ! canUnsign ) { throw new MojoExecutionException ( "neverUnsignAlreadySignedJar is set to true and a jar file [" + jarFile + " was asked to be unsign,\n please prefer use in this case an extension for " + "signed jars or not set to true the neverUnsignAlreadySignedJar parameter, Make " + "your choice:)" ) ; } verboseLog ( "Remove signature " + toProcessFile ( jarFile ) . getName ( ) ) ; signTool . unsign ( jarFile , isVerbose ( ) ) ; } else { verboseLog ( "Skip not signed " + toProcessFile ( jarFile ) . getName ( ) ) ; } } ioUtil . removeDirectory ( tempDir ) ; return jarFiles . length ; }
|
Removes the signature of the files in the specified directory which satisfy the specified filter .
|
40,209
|
private void checkConfiguration ( ) throws MojoExecutionException { checkDependencyFilenameStrategy ( ) ; if ( CollectionUtils . isEmpty ( jnlpFiles ) ) { throw new MojoExecutionException ( "Configuration error: At least one <jnlpFile> element must be specified" ) ; } if ( jnlpFiles . size ( ) == 1 && StringUtils . isEmpty ( jnlpFiles . get ( 0 ) . getOutputFilename ( ) ) ) { getLog ( ) . debug ( "Jnlp output file name not specified in single set of jnlpFiles. " + "Using default output file name: launch.jnlp." ) ; jnlpFiles . get ( 0 ) . setOutputFilename ( "launch.jnlp" ) ; } Set < String > filenames = new LinkedHashSet < > ( jnlpFiles . size ( ) ) ; for ( JnlpFile jnlpFile : jnlpFiles ) { if ( ! filenames . add ( jnlpFile . getOutputFilename ( ) ) ) { throw new MojoExecutionException ( "Configuration error: Unique JNLP filenames must be provided. " + "The following file name appears more than once [" + jnlpFile . getOutputFilename ( ) + "]." ) ; } checkJnlpFileConfiguration ( jnlpFile ) ; } if ( CollectionUtils . isNotEmpty ( commonJarResources ) ) { for ( JarResource jarResource : commonJarResources ) { checkMandatoryJarResourceFields ( jarResource ) ; if ( jarResource . getMainClass ( ) != null ) { throw new MojoExecutionException ( "Configuration Error: A mainClass must not be specified " + "on a JarResource in the commonJarResources collection." ) ; } } for ( JnlpFile jnlpFile : jnlpFiles ) { for ( JarResource jarResource : jnlpFile . getJarResources ( ) ) { if ( commonJarResources . contains ( jarResource ) ) { String message = "Configuration Error: The jar resource element for artifact " + jarResource + " defined in common jar resources is duplicated in the jar " + "resources configuration of the jnlp file identified by the template file " + jnlpFile . getInputTemplate ( ) + "." ; throw new MojoExecutionException ( message ) ; } } } } }
|
Confirms that all plugin configuration provided by the user in the pom . xml file is valid .
|
40,210
|
private void checkJnlpFileConfiguration ( JnlpFile jnlpFile ) throws MojoExecutionException { if ( StringUtils . isBlank ( jnlpFile . getOutputFilename ( ) ) ) { throw new MojoExecutionException ( "Configuration error: An outputFilename must be specified for each jnlpFile element" ) ; } if ( StringUtils . isNotBlank ( jnlpFile . getTemplateFilename ( ) ) ) { getLog ( ) . warn ( "jnlpFile.templateFilename is deprecated (since 1.0-beta-5), use now the jnlpFile.inputTemplate instead." ) ; jnlpFile . setInputTemplate ( jnlpFile . getTemplateFilename ( ) ) ; } List < JarResource > jnlpJarResources = jnlpFile . getJarResources ( ) ; if ( CollectionUtils . isEmpty ( jnlpJarResources ) ) { throw new MojoExecutionException ( "Configuration error: A non-empty <jarResources> element must be specified in the plugin " + "configuration for the JNLP file named [" + jnlpFile . getOutputFilename ( ) + "]" ) ; } JarResource mainJarResource = null ; for ( JarResource jarResource : jnlpJarResources ) { checkMandatoryJarResourceFields ( jarResource ) ; if ( jarResource . getMainClass ( ) != null ) { if ( mainJarResource != null ) { throw new MojoExecutionException ( "Configuration error: More than one <jarResource> element has been declared " + "with a <mainClass> element in the configuration for JNLP file [" + jnlpFile . getOutputFilename ( ) + "]" ) ; } jnlpFile . setMainClass ( jarResource . getMainClass ( ) ) ; mainJarResource = jarResource ; } } if ( mainJarResource == null ) { throw new MojoExecutionException ( "Configuration error: Exactly one <jarResource> element must " + "be declared with a <mainClass> element in the configuration for JNLP file [" + jnlpFile . getOutputFilename ( ) + "]" ) ; } }
|
Checks the validity of a single jnlpFile configuration element .
|
40,211
|
private void generateVersionXml ( Set < ResolvedJarResource > jarResources ) throws MojoExecutionException { VersionXmlGenerator generator = new VersionXmlGenerator ( getEncoding ( ) ) ; generator . generate ( getLibDirectory ( ) , jarResources ) ; }
|
Generates a version . xml file for all the jarResources configured either in jnlpFile elements or in the commonJarResources element .
|
40,212
|
private String getUrlPrefix ( HttpServletRequest req ) { StringBuilder url = new StringBuilder ( ) ; String scheme = req . getScheme ( ) ; int port = req . getServerPort ( ) ; url . append ( scheme ) ; url . append ( "://" ) ; url . append ( req . getServerName ( ) ) ; if ( ( scheme . equals ( "http" ) && port != 80 ) || ( scheme . equals ( "https" ) && port != 443 ) ) { url . append ( ':' ) ; url . append ( req . getServerPort ( ) ) ; } return url . toString ( ) ; }
|
This code is heavily inspired by the stuff in HttpUtils . getRequestURL
|
40,213
|
private void validateRequest ( DownloadRequest dreq ) throws ErrorResponseException { String path = dreq . getPath ( ) ; if ( path . endsWith ( ResourceCatalog . VERSION_XML_FILENAME ) || path . indexOf ( "__" ) != - 1 ) { throw new ErrorResponseException ( DownloadResponse . getNoContentResponse ( ) ) ; } }
|
Make sure that it is a valid request . This is also the place to implement the reverse IP lookup
|
40,214
|
private JnlpResource locateResource ( DownloadRequest dreq ) throws IOException , ErrorResponseException { if ( dreq . getVersion ( ) == null ) { return handleBasicDownload ( dreq ) ; } else { return handleVersionRequest ( dreq ) ; } }
|
Interprets the download request and convert it into a resource that is part of the Web Archive .
|
40,215
|
private DownloadResponse constructResponse ( JnlpResource jnlpres , DownloadRequest dreq ) throws IOException { String path = jnlpres . getPath ( ) ; if ( jnlpres . isJnlpFile ( ) ) { boolean supportQuery = JarDiffHandler . isJavawsVersion ( dreq , "1.5+" ) ; _log . addDebug ( "SupportQuery in Href: " + supportQuery ) ; if ( supportQuery ) { return _jnlpFileHandler . getJnlpFileEx ( jnlpres , dreq ) ; } else { return _jnlpFileHandler . getJnlpFile ( jnlpres , dreq ) ; } } if ( dreq . getCurrentVersionId ( ) != null && jnlpres . isJarFile ( ) ) { DownloadResponse response = _jarDiffHandler . getJarDiffEntry ( _resourceCatalog , dreq , jnlpres ) ; if ( response != null ) { _log . addInformational ( "servlet.log.info.jardiff.response" ) ; return response ; } } JnlpResource jr = new JnlpResource ( getServletContext ( ) , jnlpres . getName ( ) , jnlpres . getVersionId ( ) , jnlpres . getOSList ( ) , jnlpres . getArchList ( ) , jnlpres . getLocaleList ( ) , jnlpres . getPath ( ) , jnlpres . getReturnVersionId ( ) , dreq . getEncoding ( ) ) ; _log . addDebug ( "Real resource returned: " + jr ) ; return DownloadResponse . getFileDownloadResponse ( jr . getResource ( ) , jr . getMimeType ( ) , jr . getLastModified ( ) , jr . getReturnVersionId ( ) ) ; }
|
Given a DownloadPath and a DownloadRequest it constructs the data stream to return to the requester
|
40,216
|
private boolean matchTuple ( Object o ) { if ( o == null || ! ( o instanceof VersionID ) ) { return false ; } VersionID vid = ( VersionID ) o ; String [ ] t1 = normalize ( _tuple , vid . _tuple . length ) ; String [ ] t2 = normalize ( vid . _tuple , _tuple . length ) ; for ( int i = 0 ; i < t1 . length ; i ++ ) { Object o1 = getValueAsObject ( t1 [ i ] ) ; Object o2 = getValueAsObject ( t2 [ i ] ) ; if ( ! o1 . equals ( o2 ) ) { return false ; } } return true ; }
|
Compares if two version IDs are equal
|
40,217
|
private boolean isGreaterThanOrEqualHelper ( VersionID vid , boolean allowEqual ) { if ( _isCompound ) { if ( ! _rest . isGreaterThanOrEqualHelper ( vid , allowEqual ) ) { return false ; } } String [ ] t1 = normalize ( _tuple , vid . _tuple . length ) ; String [ ] t2 = normalize ( vid . _tuple , _tuple . length ) ; for ( int i = 0 ; i < t1 . length ; i ++ ) { Object e1 = getValueAsObject ( t1 [ i ] ) ; Object e2 = getValueAsObject ( t2 [ i ] ) ; if ( e1 . equals ( e2 ) ) { } else { if ( e1 instanceof Integer && e2 instanceof Integer ) { return ( Integer ) e1 > ( Integer ) e2 ; } else { String s1 = t1 [ i ] ; String s2 = t2 [ i ] ; return s1 . compareTo ( s2 ) > 0 ; } } } return allowEqual ; }
|
Compares if this is greater than vid
|
40,218
|
public boolean isPrefixMatch ( VersionID vid ) { if ( _isCompound ) { if ( ! _rest . isPrefixMatch ( vid ) ) { return false ; } } String [ ] t2 = normalize ( vid . _tuple , _tuple . length ) ; for ( int i = 0 ; i < _tuple . length ; i ++ ) { Object e1 = _tuple [ i ] ; Object e2 = t2 [ i ] ; if ( e1 . equals ( e2 ) ) { } else { return false ; } } return true ; }
|
Checks if this is a prefix of vid
|
40,219
|
private String [ ] normalize ( String [ ] list , int minlength ) { if ( list . length < minlength ) { String [ ] newlist = new String [ minlength ] ; System . arraycopy ( list , 0 , newlist , 0 , list . length ) ; Arrays . fill ( newlist , list . length , newlist . length , "0" ) ; return newlist ; } else { return list ; } }
|
Normalize an array to a certain length
|
40,220
|
private Manifest createManifest ( File jar , Map < String , String > manifestentries ) throws MojoExecutionException { JarFile jarFile = null ; try { jarFile = new JarFile ( jar ) ; Manifest manifest = jarFile . getManifest ( ) ; if ( manifest == null || manifest . getMainAttributes ( ) . isEmpty ( ) ) { manifest = new Manifest ( ) ; manifest . getMainAttributes ( ) . putValue ( Attributes . Name . MANIFEST_VERSION . toString ( ) , "1.0" ) ; } Set < Map . Entry < String , String > > entrySet = manifestentries . entrySet ( ) ; for ( Map . Entry < String , String > entry : entrySet ) { manifest . getMainAttributes ( ) . putValue ( entry . getKey ( ) , entry . getValue ( ) ) ; } return manifest ; } catch ( IOException e ) { throw new MojoExecutionException ( "Error while reading manifest from " + jar . getAbsolutePath ( ) , e ) ; } finally { ioUtil . close ( jarFile ) ; } }
|
Create the new manifest from the existing jar file and the new entries .
|
40,221
|
public boolean contains ( VersionID m ) { for ( Object _versionId : _versionIds ) { VersionID vi = ( VersionID ) _versionId ; boolean check = vi . match ( m ) ; if ( check ) { return true ; } } return false ; }
|
Check if this VersionString object contains the VersionID m
|
40,222
|
public boolean containsGreaterThan ( VersionID m ) { for ( Object _versionId : _versionIds ) { VersionID vi = ( VersionID ) _versionId ; boolean check = vi . isGreaterThan ( m ) ; if ( check ) { return true ; } } return false ; }
|
Check if this VersionString object contains anything greater than m
|
40,223
|
public JarSignerRequest createSignRequest ( File jarToSign , File signedJar ) throws MojoExecutionException { JarSignerSignRequest request = new JarSignerSignRequest ( ) ; request . setAlias ( getAlias ( ) ) ; request . setKeystore ( getKeystore ( ) ) ; request . setSigfile ( getSigfile ( ) ) ; request . setStoretype ( getStoretype ( ) ) ; request . setWorkingDirectory ( workDirectory ) ; request . setMaxMemory ( getMaxMemory ( ) ) ; request . setVerbose ( isVerbose ( ) ) ; request . setArchive ( jarToSign ) ; request . setSignedjar ( signedJar ) ; request . setTsaLocation ( getTsaLocation ( ) ) ; request . setProviderArg ( getProviderArg ( ) ) ; request . setProviderClass ( getProviderClass ( ) ) ; request . setKeypass ( decrypt ( keypass ) ) ; request . setStorepass ( decrypt ( storepass ) ) ; if ( ! arguments . isEmpty ( ) ) { request . setArguments ( arguments . toArray ( new String [ arguments . size ( ) ] ) ) ; } return request ; }
|
Creates a jarsigner request to do a sign operation .
|
40,224
|
public JarSignerRequest createVerifyRequest ( File jarFile , boolean certs ) { JarSignerVerifyRequest request = new JarSignerVerifyRequest ( ) ; request . setCerts ( certs ) ; request . setWorkingDirectory ( workDirectory ) ; request . setMaxMemory ( getMaxMemory ( ) ) ; request . setVerbose ( isVerbose ( ) ) ; request . setArchive ( jarFile ) ; return request ; }
|
Creates a jarsigner request to do a verify operation .
|
40,225
|
public KeyToolGenerateKeyPairRequest createKeyGenRequest ( File keystoreFile ) { KeyToolGenerateKeyPairRequest request = new KeyToolGenerateKeyPairRequest ( ) ; request . setAlias ( getAlias ( ) ) ; request . setDname ( getDname ( ) ) ; request . setKeyalg ( getKeyalg ( ) ) ; request . setKeypass ( getKeypass ( ) ) ; request . setKeysize ( getKeysize ( ) ) ; request . setKeystore ( getKeystore ( ) ) ; request . setSigalg ( getSigalg ( ) ) ; request . setStorepass ( getStorepass ( ) ) ; request . setStoretype ( getStoretype ( ) ) ; request . setValidity ( getValidity ( ) ) ; request . setVerbose ( isVerbose ( ) ) ; request . setWorkingDirectory ( workDirectory ) ; return request ; }
|
Creates a keytool request to do a key store generation operation .
|
40,226
|
public void onBrowserEvent ( Context context , Element elem , final T object , NativeEvent event ) { final int index = context . getIndex ( ) ; ValueUpdater < C > valueUpdater = ( fieldUpdater == null ) ? null : ( ValueUpdater < C > ) value -> { fieldUpdater . update ( index , object , value ) ; } ; cell . onBrowserEvent ( context , elem , getValue ( object ) , event , valueUpdater ) ; }
|
Handle a browser event that took place within the column .
|
40,227
|
public void render ( Context context , T object , SafeHtmlBuilder sb ) { cell . render ( context , getValue ( object ) , sb ) ; }
|
Render the object into the cell .
|
40,228
|
public final void setStyleProperty ( StyleName styleName , String value ) { if ( styleProps == null ) { styleProps = new HashMap < > ( ) ; } styleProps . put ( styleName , value ) ; }
|
Set a style property using its name as the key . Please ensure the style name and value are appropriately configured or it may result in unexpected behavior .
|
40,229
|
public final String getStyleProperty ( StyleName styleName ) { return styleProps != null ? styleProps . get ( styleName ) : null ; }
|
Get a styles property .
|
40,230
|
public final void setWidth ( String width ) { this . width = width ; this . dynamicWidth = width != null && width . contains ( "%" ) ; }
|
Set the columns header width .
|
40,231
|
public void loaded ( int startIndex , List < T > data , boolean cacheData ) { loaded ( startIndex , data , getTotalRows ( ) , cacheData ) ; }
|
Provide the option to load data with a cache parameter .
|
40,232
|
public int getVisibleRowCapacity ( ) { int rh = getCalculatedRowHeight ( ) ; double visibleHeight = getVisibleHeight ( ) ; int rows = ( int ) ( ( visibleHeight < 1 ) ? 0 : Math . floor ( visibleHeight / rh ) ) ; int calcHeight = rh * rows ; while ( calcHeight < visibleHeight ) { rows ++ ; calcHeight = rh * rows ; } logger . finest ( "row height: " + rh + " visibleHeight: " + visibleHeight + " visible rows: " + rows + " calcHeight: " + calcHeight ) ; return rows ; }
|
Returns the total number of rows that are visible given the current grid height .
|
40,233
|
public FrozenProperties setHeaderStyleProperty ( StyleName styleName , String value ) { headerStyleProps . put ( styleName , value ) ; return this ; }
|
Set a header style property using its name as the key . Please ensure the style name and value are appropriately configured or it may result in unexpected behavior .
|
40,234
|
public boolean isFocusable ( Element elem ) { return focusableTypes . contains ( elem . getTagName ( ) . toLowerCase ( Locale . ROOT ) ) || elem . getTabIndex ( ) >= 0 ; }
|
Check if an element is focusable . If an element is focusable the cell widget should not steal focus from it .
|
40,235
|
public final void sinkEvents ( Widget widget , Set < String > typeNames ) { if ( typeNames == null ) { return ; } int eventsToSink = 0 ; for ( String typeName : typeNames ) { int typeInt = Event . getTypeInt ( typeName ) ; if ( typeInt < 0 ) { widget . sinkBitlessEvent ( typeName ) ; } else { typeInt = sinkEvent ( widget , typeName ) ; if ( typeInt > 0 ) { eventsToSink |= typeInt ; } } } if ( eventsToSink > 0 ) { widget . sinkEvents ( eventsToSink ) ; } }
|
Sink events on the widget .
|
40,236
|
public void delay ( int delay ) { timer . cancel ( ) ; if ( delay > 0 ) { timer . schedule ( delay ) ; } else { timer . run ( ) ; } }
|
Cancels any running timers and starts a new one .
|
40,237
|
public void apply ( HasWidgets container ) { container . clear ( ) ; container . add ( topPanel ) ; container . add ( tableBody ) ; container . add ( xScrollPanel ) ; topPanel . add ( infoPanel ) ; topPanel . add ( toolPanel ) ; tableBody . add ( wrapInnerScroll ( table ) ) ; table . addHead ( new MaterialWidget ( DOM . createElement ( "thead" ) ) ) ; table . addBody ( new MaterialWidget ( DOM . createElement ( "tbody" ) ) ) ; }
|
Apply the scaffolding together .
|
40,238
|
public final TableSubHeader render ( int columnCount ) { TableSubHeader element = getWidget ( ) ; if ( element == null ) { element = new TableSubHeader ( this , columnCount ) ; setWidget ( element ) ; } render ( element , columnCount ) ; return element ; }
|
Render the data category row element .
|
40,239
|
protected void onLoad ( ) { super . onLoad ( ) ; if ( limit == 0 ) { limit = limitOptions [ 0 ] ; } add ( actionsPanel ) ; add ( rowSelection ) ; if ( pageSelection == null ) { pageSelection = new PageNumberBox ( this ) ; } add ( pageSelection ) ; firstPage ( ) ; }
|
Initialize the data pager for navigation
|
40,240
|
protected void doLoad ( int offset , int limit ) { dataSource . load ( new LoadConfig < > ( offset , limit , table . getView ( ) . getSortContext ( ) , table . getView ( ) . getOpenCategories ( ) ) , new LoadCallback < T > ( ) { public void onSuccess ( LoadResult < T > loadResult ) { setOffset ( loadResult . getOffset ( ) ) ; totalRows = loadResult . getTotalLength ( ) ; table . setVisibleRange ( loadResult . getOffset ( ) , loadResult . getData ( ) . size ( ) ) ; table . loaded ( loadResult . getOffset ( ) , loadResult . getData ( ) ) ; updateUi ( ) ; } public void onFailure ( Throwable caught ) { GWT . log ( "Load failure" , caught ) ; } } ) ; }
|
Load the datasource within a given offset and limit
|
40,241
|
protected void updateUi ( ) { pageSelection . updatePageNumber ( currentPage ) ; pageSelection . updateTotalPages ( getTotalPages ( ) ) ; int firstRow = offset + 1 ; int lastRow = ( isExcess ( ) & isLastPage ( ) ) ? totalRows : ( offset + limit ) ; actionsPanel . getActionLabel ( ) . setText ( ( firstRow == lastRow ? lastRow : firstRow + "-" + lastRow ) + " of " + totalRows ) ; actionsPanel . getIconNext ( ) . setEnabled ( true ) ; actionsPanel . getIconPrev ( ) . setEnabled ( true ) ; if ( ! isNext ( ) ) { actionsPanel . getIconNext ( ) . setEnabled ( false ) ; } if ( ! isPrevious ( ) ) { actionsPanel . getIconPrev ( ) . setEnabled ( false ) ; } }
|
Set and update the ui fields of the pager after the datasource load callback
|
40,242
|
public void setSize ( final int X , final int Y , final int WIDTH , final int HEIGHT ) { bounds . setBounds ( X , Y , WIDTH , HEIGHT ) ; fireStateChanged ( ) ; }
|
Sets the width and height of the gauge
|
40,243
|
public void setMinValue ( final double MIN_VALUE ) { if ( Double . compare ( MIN_VALUE , maxValue ) == 0 ) { throw new IllegalArgumentException ( "Min value cannot be equal to max value" ) ; } if ( Double . compare ( MIN_VALUE , maxValue ) > 0 ) { minValue = maxValue ; maxValue = MIN_VALUE ; } else { minValue = MIN_VALUE ; } calculate ( ) ; validate ( ) ; calcAngleStep ( ) ; fireStateChanged ( ) ; }
|
Sets the minium value that will be used for the calculation of the nice minimum value for the scale .
|
40,244
|
public void setMaxValue ( final double MAX_VALUE ) { if ( Double . compare ( MAX_VALUE , minValue ) == 0 ) { throw new IllegalArgumentException ( "Max value cannot be equal to min value" ) ; } if ( Double . compare ( MAX_VALUE , minValue ) < 0 ) { maxValue = minValue ; minValue = MAX_VALUE ; } else { maxValue = MAX_VALUE ; } calculate ( ) ; validate ( ) ; calcAngleStep ( ) ; fireStateChanged ( ) ; }
|
Sets the maximum value that will be used for the calculation of the nice maximum vlaue for the scale .
|
40,245
|
public void setRange ( final double MIN_VALUE , final double MAX_VALUE ) { maxValue = MAX_VALUE ; minValue = MIN_VALUE ; calculate ( ) ; validate ( ) ; calcAngleStep ( ) ; fireStateChanged ( ) ; }
|
Sets the minimum and maximum value for the calculation of the nice minimum and nice maximum values .
|
40,246
|
public void setValue ( final double VALUE ) { oldValue = value ; value = VALUE < niceMinValue ? niceMinValue : ( VALUE > niceMaxValue ? niceMaxValue : VALUE ) ; fireStateChanged ( ) ; }
|
Sets the current value of the gauge
|
40,247
|
public void setRedrawTolerance ( final double REDRAW_TOLERANCE ) { redrawTolerance = REDRAW_TOLERANCE < 0 ? 0 : ( REDRAW_TOLERANCE > 1 ? 1.0 : REDRAW_TOLERANCE ) ; redrawFactor = redrawTolerance * getRange ( ) ; fireStateChanged ( ) ; }
|
Sets the redraw tolerance
|
40,248
|
public void setThreshold ( final double THRESHOLD ) { if ( Double . compare ( THRESHOLD , minValue ) >= 0 && Double . compare ( THRESHOLD , maxValue ) <= 0 ) { threshold = THRESHOLD ; } else { if ( THRESHOLD < niceMinValue ) { threshold = niceMinValue ; } if ( THRESHOLD > niceMaxValue ) { threshold = niceMaxValue ; } } fireStateChanged ( ) ; }
|
Sets the value for the threshold of the gauge
|
40,249
|
public void setMinMeasuredValue ( final double MIN_MEASURED_VALUE ) { if ( Double . compare ( MIN_MEASURED_VALUE , niceMinValue ) >= 0 && Double . compare ( MIN_MEASURED_VALUE , niceMaxValue ) <= 0 ) { minMeasuredValue = MIN_MEASURED_VALUE ; } else { if ( MIN_MEASURED_VALUE < niceMinValue ) { minMeasuredValue = niceMinValue ; } if ( MIN_MEASURED_VALUE > niceMaxValue ) { minMeasuredValue = niceMaxValue ; } } createRadialShapeOfMeasureValuesArea ( ) ; fireStateChanged ( ) ; }
|
Sets the minimum measured value of the gauge to the given value
|
40,250
|
public void resetMinMeasuredValue ( final double MIN_MEASURED_VALUE ) { minMeasuredValue = MIN_MEASURED_VALUE < niceMinValue ? niceMinValue : ( MIN_MEASURED_VALUE > niceMaxValue ? niceMaxValue : MIN_MEASURED_VALUE ) ; createRadialShapeOfMeasureValuesArea ( ) ; fireStateChanged ( ) ; }
|
Resets the minimum measured value of the gauge to the given value
|
40,251
|
public void setMaxMeasuredValue ( final double MAX_MEASURED_VALUE ) { if ( Double . compare ( MAX_MEASURED_VALUE , niceMinValue ) >= 0 && Double . compare ( MAX_MEASURED_VALUE , niceMaxValue ) <= 0 ) { maxMeasuredValue = MAX_MEASURED_VALUE ; } else { if ( MAX_MEASURED_VALUE < niceMinValue ) { maxMeasuredValue = niceMinValue ; } if ( MAX_MEASURED_VALUE > niceMaxValue ) { maxMeasuredValue = niceMaxValue ; } } createRadialShapeOfMeasureValuesArea ( ) ; fireStateChanged ( ) ; }
|
Sets the maximum measured value of the gauge to the given value
|
40,252
|
public void resetMaxMeasuredValue ( final double MAX_MEASURED_VALUE ) { maxMeasuredValue = MAX_MEASURED_VALUE < niceMinValue ? niceMinValue : ( MAX_MEASURED_VALUE > niceMaxValue ? niceMaxValue : MAX_MEASURED_VALUE ) ; createRadialShapeOfMeasureValuesArea ( ) ; fireStateChanged ( ) ; }
|
Resets the maximum measured value of the gauge to the given value
|
40,253
|
public void setTrackStart ( final double TRACK_START ) { if ( Double . compare ( TRACK_START , trackStop ) == 0 ) { throw new IllegalArgumentException ( "Track start value cannot equal track stop value" ) ; } trackStart = TRACK_START ; validate ( ) ; fireStateChanged ( ) ; }
|
Sets the track start value of the gauge to the given value
|
40,254
|
public void setTrackStop ( final double TRACK_STOP ) { if ( Double . compare ( trackStart , TRACK_STOP ) == 0 ) { throw new IllegalArgumentException ( "Track stop value cannot equal track start value" ) ; } trackStop = TRACK_STOP ; validate ( ) ; fireStateChanged ( ) ; }
|
Sets the track stop value of the gauge to the given value
|
40,255
|
public void setSections ( Section ... SECTIONS_ARRAY ) { sections . clear ( ) ; for ( Section section : SECTIONS_ARRAY ) { sections . add ( new Section ( section . getStart ( ) , section . getStop ( ) , section . getColor ( ) ) ) ; } validate ( ) ; fireStateChanged ( ) ; }
|
Sets the sections of the gauge to the given array of section objects
|
40,256
|
public List < Section > getAreas ( ) { List < Section > areasCopy = new ArrayList < Section > ( 10 ) ; areasCopy . addAll ( areas ) ; return areasCopy ; }
|
Returns a list of section objects that will used to display the areas of a gauge with their colors .
|
40,257
|
public void setAreas ( Section ... AREAS_ARRAY ) { areas . clear ( ) ; for ( Section area : AREAS_ARRAY ) { areas . add ( new Section ( area . getStart ( ) , area . getStop ( ) , area . getColor ( ) ) ) ; } validate ( ) ; fireStateChanged ( ) ; }
|
Sets the areas of the gauge to the given array of section objects
|
40,258
|
public List < Section > getTickmarkSections ( ) { List < Section > tickmarkSectionsCopy = new ArrayList < Section > ( 10 ) ; tickmarkSectionsCopy . addAll ( tickmarkSections ) ; return tickmarkSectionsCopy ; }
|
Returns a list of section objects that will be used to display to display the tickmark sections of a gauge with their different colors .
|
40,259
|
public void setTickmarkSections ( final Section ... TICKMARK_SECTIONS_ARRAY ) { tickmarkSections . clear ( ) ; for ( Section tickmarkSection : TICKMARK_SECTIONS_ARRAY ) { tickmarkSections . add ( new Section ( tickmarkSection . getStart ( ) , tickmarkSection . getStop ( ) , tickmarkSection . getColor ( ) ) ) ; } validate ( ) ; fireStateChanged ( ) ; }
|
Sets the tickmark sections of the gauge to the given array of section objects
|
40,260
|
public void setMinMaxAndNoOfTicks ( final double MIN_VALUE , final double MAX_VALUE , final int NO_OF_MINOR_TICKS , final int NO_OF_MAJOR_TICKS ) { this . maxNoOfMinorTicks = NO_OF_MINOR_TICKS ; this . maxNoOfMajorTicks = NO_OF_MAJOR_TICKS ; this . minValue = MIN_VALUE ; this . maxValue = MAX_VALUE ; calculate ( ) ; }
|
Sets the minimum and maximum values and the number of minor and major tickmarks of the gauge dial
|
40,261
|
public void setMaxNoOfMajorTicks ( final int MAX_NO_OF_MAJOR_TICKS ) { if ( MAX_NO_OF_MAJOR_TICKS > 20 ) { this . maxNoOfMajorTicks = 20 ; } else if ( MAX_NO_OF_MAJOR_TICKS < 2 ) { this . maxNoOfMajorTicks = 2 ; } else { this . maxNoOfMajorTicks = MAX_NO_OF_MAJOR_TICKS ; } calculate ( ) ; fireStateChanged ( ) ; }
|
Sets the maximum number of major tickmarks we re comfortable with
|
40,262
|
public void setMaxNoOfMinorTicks ( final int MAX_NO_OF_MINOR_TICKS ) { if ( MAX_NO_OF_MINOR_TICKS > 10 ) { this . maxNoOfMinorTicks = 10 ; } else if ( MAX_NO_OF_MINOR_TICKS < 1 ) { this . maxNoOfMinorTicks = 1 ; } else { this . maxNoOfMinorTicks = MAX_NO_OF_MINOR_TICKS ; } calculate ( ) ; fireStateChanged ( ) ; }
|
Sets the maximum number of minor tickmarks we re comfortable with
|
40,263
|
public void setCustomLayer ( final BufferedImage CUSTOM_LAYER ) { if ( customLayer != null ) { customLayer . flush ( ) ; } customLayer = CUSTOM_LAYER ; fireStateChanged ( ) ; }
|
Sets the given buffered image as the custom layer of the gauge
|
40,264
|
private void calcAngleStep ( ) { final double angleRange = getAngleRange ( ) ; angleStep = angleRange / range ; logAngleStep = angleRange / ( Util . INSTANCE . logOfBase ( BASE , range ) ) ; }
|
Calculates the stepsize in rad for the given gaugetype and range
|
40,265
|
private void calculate ( ) { if ( niceScale ) { this . niceRange = calcNiceNumber ( maxValue - minValue , false ) ; this . majorTickSpacing = calcNiceNumber ( niceRange / ( maxNoOfMajorTicks - 1 ) , true ) ; this . niceMinValue = Math . floor ( minValue / majorTickSpacing ) * majorTickSpacing ; this . niceMaxValue = Math . ceil ( maxValue / majorTickSpacing ) * majorTickSpacing ; this . minorTickSpacing = calcNiceNumber ( majorTickSpacing / ( maxNoOfMinorTicks - 1 ) , true ) ; this . range = niceMaxValue - niceMinValue ; } else { this . niceRange = ( maxValue - minValue ) ; this . niceMinValue = minValue ; this . niceMaxValue = maxValue ; this . range = this . niceRange ; } }
|
Calculate and update values for majro and minor tick spacing and nice minimum and maximum values on the axis .
|
40,266
|
private double calcNiceNumber ( final double RANGE , final boolean ROUND ) { final double EXPONENT = Math . floor ( Math . log10 ( RANGE ) ) ; final double FRACTION = RANGE / Math . pow ( 10 , EXPONENT ) ; final double NICE_FRACTION ; if ( ROUND ) { if ( FRACTION < 1.5 ) { NICE_FRACTION = 1 ; } else if ( FRACTION < 3 ) { NICE_FRACTION = 2 ; } else if ( FRACTION < 7 ) { NICE_FRACTION = 5 ; } else { NICE_FRACTION = 10 ; } } else { if ( FRACTION <= 1 ) { NICE_FRACTION = 1 ; } else if ( FRACTION <= 2 ) { NICE_FRACTION = 2 ; } else if ( FRACTION <= 5 ) { NICE_FRACTION = 5 ; } else { NICE_FRACTION = 10 ; } } return NICE_FRACTION * Math . pow ( 10 , EXPONENT ) ; }
|
Returns a nice number approximately equal to the range . Rounds the number if ROUND == true . Takes the ceiling if ROUND = false .
|
40,267
|
public void addChangeListener ( javax . swing . event . ChangeListener LISTENER ) { LISTENER_LIST . add ( javax . swing . event . ChangeListener . class , LISTENER ) ; }
|
Adds the given listener to the listener list
|
40,268
|
public void removeChangeListener ( javax . swing . event . ChangeListener LISTENER ) { LISTENER_LIST . remove ( javax . swing . event . ChangeListener . class , LISTENER ) ; }
|
Removes all listeners from the listener list
|
40,269
|
protected void fireStateChanged ( ) { Object [ ] listeners = LISTENER_LIST . getListenerList ( ) ; for ( int i = listeners . length - 2 ; i >= 0 ; i -= 2 ) { if ( listeners [ i ] == javax . swing . event . ChangeListener . class ) { if ( changeEvent == null ) { changeEvent = new javax . swing . event . ChangeEvent ( this ) ; } ( ( javax . swing . event . ChangeListener ) listeners [ i + 1 ] ) . stateChanged ( changeEvent ) ; } } }
|
Fires an state change event every time the data model changes
|
40,270
|
public void setBarGraphColor ( final ColorDef BARGRAPH_COLOR ) { getModel ( ) . setValueColor ( BARGRAPH_COLOR ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . width ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the current bargraph color to the given enum colordef
|
40,271
|
public void setCustomBarGraphColor ( final Color COLOR ) { getModel ( ) . setCustomValueColorObject ( new CustomColorDef ( COLOR ) ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . width ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color that will be used to calculate the custom bargraph color
|
40,272
|
public Color getColorAt ( final float FRACTION ) { float fraction = FRACTION < 0f ? 0f : ( FRACTION > 1f ? 1f : FRACTION ) ; float lowerLimit = 0f ; int lowerIndex = 0 ; float upperLimit = 1f ; int upperIndex = 1 ; int index = 0 ; for ( float currentFraction : fractions ) { if ( Float . compare ( currentFraction , fraction ) < 0 ) { lowerLimit = currentFraction ; lowerIndex = index ; } if ( Float . compare ( currentFraction , fraction ) == 0 ) { return colors [ index ] ; } if ( Float . compare ( currentFraction , fraction ) > 0 ) { upperLimit = currentFraction ; upperIndex = index ; break ; } index ++ ; } float interpolationFraction = ( fraction - lowerLimit ) / ( upperLimit - lowerLimit ) ; return interpolateColor ( colors [ lowerIndex ] , colors [ upperIndex ] , interpolationFraction ) ; }
|
Returns the color that is defined by the given fraction in the linear gradient paint
|
40,273
|
private void copyArrays ( final float [ ] FRACTIONS , final Color [ ] colors ) { fractions = new float [ FRACTIONS . length ] ; System . arraycopy ( FRACTIONS , 0 , fractions , 0 , FRACTIONS . length ) ; this . colors = colors . clone ( ) ; }
|
Just create a local copy of the fractions and colors array
|
40,274
|
protected BufferedImage create_BARGRAPH_LED_Image ( final int WIDTH , final int HEIGHT , final ColorDef COLOR , final Color [ ] CUSTOM_COLORS ) { if ( WIDTH <= 20 || HEIGHT <= 20 ) { return UTIL . createImage ( 1 , 1 , Transparency . TRANSLUCENT ) ; } final int IMAGE_WIDTH ; final int IMAGE_HEIGHT ; if ( getOrientation ( ) == Orientation . VERTICAL ) { IMAGE_WIDTH = ( int ) ( WIDTH * 0.1214285714 ) ; IMAGE_HEIGHT = ( int ) ( HEIGHT * 0.0121359223 ) ; } else { IMAGE_HEIGHT = ( int ) ( WIDTH * 0.0121359223 ) ; IMAGE_WIDTH = ( int ) ( HEIGHT * 0.1214285714 ) ; } final BufferedImage IMAGE = UTIL . createImage ( IMAGE_WIDTH , IMAGE_HEIGHT , Transparency . TRANSLUCENT ) ; final Graphics2D G2 = IMAGE . createGraphics ( ) ; G2 . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; final Rectangle2D LED = new Rectangle2D . Double ( 0 , 0 , IMAGE_WIDTH , IMAGE_HEIGHT ) ; final Point2D CENTER = new Point2D . Double ( LED . getCenterX ( ) , LED . getCenterY ( ) ) ; final float [ ] FRACTIONS = { 0.0f , 1.0f } ; final Color [ ] COLORS ; if ( CUSTOM_COLORS != null && CUSTOM_COLORS . length == 2 ) { COLORS = CUSTOM_COLORS ; } else { COLORS = new Color [ ] { COLOR . LIGHT , COLOR . DARK } ; } final float RADIUS ; switch ( getOrientation ( ) ) { case VERTICAL : default : RADIUS = ( float ) ( LED . getWidth ( ) / 2f ) ; break ; case HORIZONTAL : RADIUS = ( float ) ( LED . getHeight ( ) / 2f ) ; break ; } final RadialGradientPaint GRADIENT = new RadialGradientPaint ( CENTER , RADIUS , FRACTIONS , COLORS ) ; G2 . setPaint ( GRADIENT ) ; G2 . fill ( LED ) ; G2 . dispose ( ) ; return IMAGE ; }
|
Returns a buffered image of a bargraph led with the given color
|
40,275
|
public void setSectionsVisible ( final boolean SECTIONS_VISIBLE ) { sectionsVisible = SECTIONS_VISIBLE ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the visibility of the sections . The sections could be defined by a start value a stop value and a color . One has to create a Section object from the class Section . The sections are stored in a ArrayList so there could be multiple . This might be a useful feature if you need to have exactly defined areas that you could not visualize with the track feature .
|
40,276
|
public List < Section > getSections ( ) { List < Section > sectionsCopy = new ArrayList < Section > ( sections . size ( ) ) ; sectionsCopy . addAll ( sections ) ; return sectionsCopy ; }
|
Returns a copy of the ArrayList that stores the sections . The sections could be defined by a start value a stop value and a color . One has to create a Section object from the class Section . The sections are stored in a ArrayList so there could be multiple . This might be a useful feature if you need to have exactly defined areas that you could not visualize with the track feature .
|
40,277
|
public void addSection ( final Section SECTION ) { sections . add ( SECTION ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Adds a given section to the list of sections The sections could be defined by a start value a stop value and a color . One has to create a Section object from the class Section . The sections are stored in a ArrayList so there could be multiple . This might be a useful feature if you need to have exactly defined areas that you could not visualize with the track feature .
|
40,278
|
public void resetSections ( ) { sections . clear ( ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Clear the SECTIONS arraylist
|
40,279
|
public void setValue ( final double VALUE ) { if ( isEnabled ( ) ) { this . value100 = ( VALUE % 1000 ) / 100 ; this . value1000 = ( VALUE % 10000 ) / 100 ; this . value10000 = ( VALUE % 100000 ) / 100 ; if ( isValueCoupled ( ) ) { setLcdValue ( VALUE ) ; } fireStateChanged ( ) ; this . oldValue = VALUE ; repaint ( ) ; } }
|
Sets the current height in feet
|
40,280
|
public void setDirection ( final int DIRECTION ) { switch ( DIRECTION ) { case SwingUtilities . SOUTH : direction = SwingUtilities . SOUTH ; break ; case SwingUtilities . EAST : direction = SwingUtilities . EAST ; break ; case SwingUtilities . WEST : direction = SwingUtilities . WEST ; break ; case SwingUtilities . NORTH : default : direction = SwingUtilities . NORTH ; break ; } repaint ( getInnerBounds ( ) ) ; }
|
Sets the direction of the lightbulb . Use the constants defined in SwingUtilities SwingUtilities . NORTH SwingUtilities . EAST SwingUtiltites . SOUTH SwingUtilities . WEST
|
40,281
|
private BufferedImage createImage ( final int WIDTH , final int HEIGHT , final int TRANSPARENCY ) { final GraphicsConfiguration GFX_CONF = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) . getDefaultScreenDevice ( ) . getDefaultConfiguration ( ) ; if ( WIDTH <= 0 || HEIGHT <= 0 ) { return GFX_CONF . createCompatibleImage ( 1 , 1 , TRANSPARENCY ) ; } final BufferedImage IMAGE = GFX_CONF . createCompatibleImage ( WIDTH , HEIGHT , TRANSPARENCY ) ; return IMAGE ; }
|
Returns a compatible image of the given size and transparency
|
40,282
|
private java . util . HashMap < Float , Color > recalculate ( final List < Float > fractionList , final List < Color > colorList , final float OFFSET ) { final int MAX_FRACTIONS = fractionList . size ( ) ; final HashMap < Float , Color > fractionColors = new HashMap < Float , Color > ( MAX_FRACTIONS ) ; for ( int i = 0 ; i < MAX_FRACTIONS ; i ++ ) { final float TMP_FRACTION = fractionList . get ( i ) + OFFSET ; final Color TMP_COLOR = colorList . get ( i ) ; if ( TMP_FRACTION <= 0 ) { fractionColors . put ( 1.0f + TMP_FRACTION + 0.0001f , TMP_COLOR ) ; final float NEXT_FRACTION ; final Color NEXT_COLOR ; if ( i < MAX_FRACTIONS - 1 ) { NEXT_FRACTION = fractionList . get ( i + 1 ) + OFFSET ; NEXT_COLOR = colorList . get ( i + 1 ) ; } else { NEXT_FRACTION = 1 - fractionList . get ( 0 ) + OFFSET ; NEXT_COLOR = colorList . get ( 0 ) ; } if ( NEXT_FRACTION > 0 ) { final Color NEW_FRACTION_COLOR = getColorFromFraction ( TMP_COLOR , NEXT_COLOR , ( int ) ( ( NEXT_FRACTION - TMP_FRACTION ) * 10000 ) , ( int ) ( ( - TMP_FRACTION ) * 10000 ) ) ; fractionColors . put ( 0.0f , NEW_FRACTION_COLOR ) ; fractionColors . put ( 1.0f , NEW_FRACTION_COLOR ) ; } } else if ( TMP_FRACTION >= 1 ) { fractionColors . put ( TMP_FRACTION - 1.0f - 0.0001f , TMP_COLOR ) ; final float PREVIOUS_FRACTION ; final Color PREVIOUS_COLOR ; if ( i > 0 ) { PREVIOUS_FRACTION = fractionList . get ( i - 1 ) + OFFSET ; PREVIOUS_COLOR = colorList . get ( i - 1 ) ; } else { PREVIOUS_FRACTION = fractionList . get ( MAX_FRACTIONS - 1 ) + OFFSET ; PREVIOUS_COLOR = colorList . get ( MAX_FRACTIONS - 1 ) ; } if ( PREVIOUS_FRACTION < 1 ) { final Color NEW_FRACTION_COLOR = getColorFromFraction ( TMP_COLOR , PREVIOUS_COLOR , ( int ) ( ( TMP_FRACTION - PREVIOUS_FRACTION ) * 10000 ) , ( int ) ( TMP_FRACTION - 1.0f ) * 10000 ) ; fractionColors . put ( 1.0f , NEW_FRACTION_COLOR ) ; fractionColors . put ( 0.0f , NEW_FRACTION_COLOR ) ; } } else { fractionColors . put ( TMP_FRACTION , TMP_COLOR ) ; } } fractionList . clear ( ) ; colorList . clear ( ) ; return fractionColors ; }
|
Recalculates the fractions in the FRACTION_LIST and their associated colors in the COLOR_LIST with a given OFFSET . Because the conical gradients always starts with 0 at the top and clockwise direction you could rotate the defined conical gradient from - 180 to 180 degrees which equals values from - 0 . 5 to + 0 . 5
|
40,283
|
public void setValue ( final double VALUE ) { if ( isEnabled ( ) ) { if ( ! isLogScale ( ) ) { model . setValue ( VALUE ) ; } else { if ( VALUE > 0 ) { model . setValue ( VALUE ) ; } else { model . setValue ( 1 ) ; } } if ( ! isAutoResetToZero ( ) ) { if ( ! model . isThresholdBehaviourInverted ( ) ) { if ( Double . compare ( model . getValue ( ) , model . getThreshold ( ) ) >= 0 ) { if ( ! LED_BLINKING_TIMER . isRunning ( ) ) { LED_BLINKING_TIMER . start ( ) ; propertyChangeSupport . firePropertyChange ( THRESHOLD_PROPERTY , false , true ) ; } } else { LED_BLINKING_TIMER . stop ( ) ; setCurrentLedImage ( getLedImageOff ( ) ) ; } } else { if ( Double . compare ( model . getValue ( ) , model . getThreshold ( ) ) <= 0 ) { if ( ! LED_BLINKING_TIMER . isRunning ( ) ) { LED_BLINKING_TIMER . start ( ) ; propertyChangeSupport . firePropertyChange ( THRESHOLD_PROPERTY , false , true ) ; } } else { LED_BLINKING_TIMER . stop ( ) ; setCurrentLedImage ( getLedImageOff ( ) ) ; } } } if ( model . getValue ( ) > ( model . getOldValue ( ) + model . getRange ( ) * model . getRedrawFactor ( ) ) || model . getValue ( ) < ( model . getOldValue ( ) - model . getRange ( ) * model . getRedrawFactor ( ) ) ) { repaint ( getInnerBounds ( ) ) ; } fireStateChanged ( ) ; propertyChangeSupport . firePropertyChange ( VALUE_PROPERTY , model . getOldValue ( ) , model . getValue ( ) ) ; } }
|
Sets the value of the gauge . This method is primarly used for static gauges or if you really have measurement results that are occuring within the range of a second . If you have slow changing values you should better use the method setValueAnimated .
|
40,284
|
public void setLedColor ( final LedColor LED_COLOR ) { model . setLedColor ( LED_COLOR ) ; final boolean LED_WAS_ON = currentLedImage . equals ( ledImageOn ) ? true : false ; switch ( getOrientation ( ) ) { case HORIZONTAL : recreateLedImages ( getHeight ( ) ) ; break ; case VERTICAL : recreateLedImages ( getWidth ( ) ) ; break ; default : recreateLedImages ( ) ; break ; } if ( currentLedImage != null ) { currentLedImage . flush ( ) ; } currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color of the threshold led dependend on the orientation of a component . This is only important for the linear gauges where the width and the height are different . The LedColor is not a standard color but defines a color scheme for the led . The default ledcolor is RED
|
40,285
|
public void setCustomLedColor ( final Color COLOR ) { model . setCustomLedColor ( new CustomLedColor ( COLOR ) ) ; final boolean LED_WAS_ON = currentLedImage . equals ( ledImageOn ) ? true : false ; switch ( getOrientation ( ) ) { case HORIZONTAL : recreateLedImages ( getHeight ( ) ) ; break ; case VERTICAL : recreateLedImages ( getWidth ( ) ) ; break ; default : recreateLedImages ( ) ; break ; } if ( currentLedImage != null ) { currentLedImage . flush ( ) ; } currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color from which the custom ledcolor will be calculated
|
40,286
|
public void setLedBlinking ( final boolean LED_BLINKING ) { ledBlinking = LED_BLINKING ; if ( LED_BLINKING ) { LED_BLINKING_TIMER . start ( ) ; } else { setCurrentLedImage ( getLedImageOff ( ) ) ; LED_BLINKING_TIMER . stop ( ) ; } }
|
Sets the state of the threshold led . The led could blink which will be triggered by a javax . swing . Timer that triggers every 500 ms . The blinking will be done by switching between two images .
|
40,287
|
protected void recreateLedImages ( final int SIZE ) { if ( ledImageOff != null ) { ledImageOff . flush ( ) ; } ledImageOff = create_LED_Image ( SIZE , 0 , model . getLedColor ( ) ) ; if ( ledImageOn != null ) { ledImageOn . flush ( ) ; } ledImageOn = create_LED_Image ( SIZE , 1 , model . getLedColor ( ) ) ; }
|
Recreates the current threshold led images due to the given width
|
40,288
|
protected void setCurrentLedImage ( final BufferedImage CURRENT_LED_IMAGE ) { if ( currentLedImage != null ) { currentLedImage . flush ( ) ; } currentLedImage = CURRENT_LED_IMAGE ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the image of the currently used led image .
|
40,289
|
public void setUserLedColor ( final LedColor LED_COLOR ) { model . setUserLedColor ( LED_COLOR ) ; final boolean LED_WAS_ON = currentUserLedImage . equals ( userLedImageOn ) ? true : false ; switch ( getOrientation ( ) ) { case HORIZONTAL : recreateUserLedImages ( getHeight ( ) ) ; break ; case VERTICAL : recreateUserLedImages ( getWidth ( ) ) ; break ; default : recreateUserLedImages ( ) ; break ; } if ( currentUserLedImage != null ) { currentUserLedImage . flush ( ) ; } currentUserLedImage = LED_WAS_ON == true ? userLedImageOn : userLedImageOff ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color of the user led dependend on the orientation of a component . This is only important for the linear gauges where the width and the height are different . The LedColor is not a standard color but defines a color scheme for the led . The default ledcolor is RED
|
40,290
|
public void setCustomUserLedColor ( final Color COLOR ) { model . setCustomUserLedColor ( new CustomLedColor ( COLOR ) ) ; final boolean LED_WAS_ON = currentUserLedImage . equals ( ledImageOn ) ? true : false ; switch ( getOrientation ( ) ) { case HORIZONTAL : recreateUserLedImages ( getHeight ( ) ) ; break ; case VERTICAL : recreateUserLedImages ( getWidth ( ) ) ; break ; default : recreateUserLedImages ( ) ; break ; } if ( currentUserLedImage != null ) { currentUserLedImage . flush ( ) ; } currentUserLedImage = LED_WAS_ON == true ? userLedImageOn : userLedImageOff ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color from which the custom user ledcolor will be calculated
|
40,291
|
public void setUserLedBlinking ( final boolean USER_LED_BLINKING ) { this . userLedBlinking = USER_LED_BLINKING ; if ( USER_LED_BLINKING ) { USER_LED_BLINKING_TIMER . start ( ) ; } else { setCurrentUserLedImage ( getUserLedImageOff ( ) ) ; USER_LED_BLINKING_TIMER . stop ( ) ; } }
|
Sets the state of the user led . The led could blink which will be triggered by a javax . swing . Timer that triggers every 500 ms . The blinking will be done by switching between two images .
|
40,292
|
protected void recreateUserLedImages ( final int SIZE ) { if ( userLedImageOff != null ) { userLedImageOff . flush ( ) ; } userLedImageOff = create_LED_Image ( SIZE , 0 , model . getUserLedColor ( ) ) ; if ( userLedImageOn != null ) { userLedImageOn . flush ( ) ; } userLedImageOn = create_LED_Image ( SIZE , 1 , model . getUserLedColor ( ) ) ; }
|
Recreates the current user led images due to the given width
|
40,293
|
protected void setCurrentUserLedImage ( final BufferedImage CURRENT_USER_LED_IMAGE ) { if ( currentUserLedImage != null ) { currentUserLedImage . flush ( ) ; } currentUserLedImage = CURRENT_USER_LED_IMAGE ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the image of the currently used user led image .
|
40,294
|
public void setTextureColor ( final Color TEXTURE_COLOR ) { model . setTextureColor ( TEXTURE_COLOR ) ; BACKGROUND_FACTORY . recreatePunchedSheetTexture ( TEXTURE_COLOR ) ; reInitialize ( ) ; }
|
Sets the color that will be used to render textures like Carbon PunchedSheet Linen etc .
|
40,295
|
public void setCustomBackground ( final Paint CUSTOM_BACKGROUND ) { model . setCustomBackground ( CUSTOM_BACKGROUND ) ; if ( model . getBackgroundColor ( ) == BackgroundColor . CUSTOM ) { reInitialize ( ) ; } }
|
Sets the custom background paint that will be used instead of the predefined backgroundcolors like DARK_GRAY BEIGE etc .
|
40,296
|
protected final BufferedImage create_LED_Image ( final int SIZE , final int STATE , final LedColor LED_COLOR ) { return LED_FACTORY . create_LED_Image ( SIZE , STATE , LED_COLOR , model . getCustomLedColor ( ) ) ; }
|
Returns an image of a led with the given size state and color . If the LED_COLOR parameter equals CUSTOM the userLedColor will be used to calculate the custom led colors
|
40,297
|
public void setRunning ( final boolean RUNNING ) { running = RUNNING ; if ( RUNNING ) { if ( ! CLOCK_TIMER . isRunning ( ) ) { CLOCK_TIMER . start ( ) ; start = System . currentTimeMillis ( ) ; repaint ( INNER_BOUNDS ) ; } } else { if ( CLOCK_TIMER . isRunning ( ) ) { CLOCK_TIMER . stop ( ) ; } } }
|
Start or stop the stopwatch
|
40,298
|
private void calcInnerBounds ( ) { final Insets INSETS = getInsets ( ) ; if ( yellowVisible ) { final int PREF_HEIGHT = getWidth ( ) < ( int ) ( getHeight ( ) * 0.4 ) ? ( int ) ( getWidth ( ) * 2.5 ) : getHeight ( ) ; INNER_BOUNDS . setBounds ( INSETS . left , INSETS . top , ( int ) ( PREF_HEIGHT * 0.4 ) - INSETS . left - INSETS . right , PREF_HEIGHT - INSETS . top - INSETS . bottom ) ; } else { final int PREF_HEIGHT = getWidth ( ) < ( int ) ( getHeight ( ) * 0.5714285714 ) ? ( int ) ( getWidth ( ) * 1.75 ) : getHeight ( ) ; INNER_BOUNDS . setBounds ( INSETS . left , INSETS . top , ( int ) ( PREF_HEIGHT * 0.5714285714 ) - INSETS . left - INSETS . right , PREF_HEIGHT - INSETS . top - INSETS . bottom ) ; } }
|
Calculates the area that is available for painting the display
|
40,299
|
public void setLedType ( final LedType LED_TYPE ) { if ( ledType == LED_TYPE ) { return ; } ledType = LED_TYPE ; final boolean LED_WAS_ON = currentLedImage . equals ( ledImageOn ) ? true : false ; flushImages ( ) ; ledImageOff = create_LED_Image ( getWidth ( ) , 0 , ledColor , ledType ) ; ledImageOn = create_LED_Image ( getWidth ( ) , 1 , ledColor , ledType ) ; currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff ; repaint ( ) ; }
|
Sets the type of LED .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.