idx
int64 0
41.2k
| question
stringlengths 73
5.81k
| target
stringlengths 5
918
|
|---|---|---|
40,300
|
public void setLedColor ( final LedColor LED_COLOR ) { if ( ledColor == LED_COLOR ) { return ; } if ( LED_COLOR == null ) { ledColor = LedColor . RED_LED ; } else { ledColor = LED_COLOR ; } final boolean LED_WAS_ON = currentLedImage . equals ( ledImageOn ) ? true : false ; flushImages ( ) ; ledImageOff = create_LED_Image ( getWidth ( ) , 0 , LED_COLOR , ledType ) ; ledImageOn = create_LED_Image ( getWidth ( ) , 1 , LED_COLOR , ledType ) ; currentLedImage = LED_WAS_ON == true ? ledImageOn : ledImageOff ; repaint ( ) ; }
|
Sets the color of the threshold led . The LedColor is not a standard color but defines a color scheme for the led . The default ledcolor is RED
|
40,301
|
public void setCustomLedColor ( final Color COLOR ) { if ( customLedColor . COLOR . equals ( COLOR ) ) { return ; } customLedColor = new CustomLedColor ( COLOR ) ; 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 color that will be used to calculate the custom led color
|
40,302
|
public void addDataPoint ( final int INDEX ) { FREQUENCE [ INDEX > n - 1 ? n - 1 : INDEX ] ++ ; max = FREQUENCE [ INDEX ] > max ? FREQUENCE [ INDEX ] : max ; }
|
Add one occurrence of the value i .
|
40,303
|
public void setFrameType ( final FrameType FRAME_TYPE ) { getModel ( ) . setFrameType ( FRAME_TYPE ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Defines the type of frame that will be used for the radial gauge . It could be round our square .
|
40,304
|
public void setForegroundType ( final ForegroundType FOREGROUND_TYPE ) { getModel ( ) . setForegroundType ( FOREGROUND_TYPE ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Defines the type of foreground that will be used for the radial gauge . There area three types available .
|
40,305
|
public void setLedPosition ( final double X , final double Y ) { ledPosition . setLocation ( X , Y ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the position of the gauge threshold led to the given values
|
40,306
|
public void setUserLedPosition ( final double X , final double Y ) { userLedPosition . setLocation ( X , Y ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the position of the gauge user led to the given values
|
40,307
|
public void setTickmarkDirection ( final Direction DIRECTION ) { this . tickmarkDirection = DIRECTION ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the direction of the tickmark label counting . CLOCKWISE will count in clockwise direction COUNTER_CLOCKWISE will count the opposite way
|
40,308
|
public void setPointerType ( final PointerType POINTER_TYPE ) { getModel ( ) . setPointerType ( POINTER_TYPE ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the type of the pointer
|
40,309
|
public void setPointerColor ( final ColorDef POINTER_COLOR ) { getModel ( ) . setPointerColor ( POINTER_COLOR ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color of the pointer
|
40,310
|
public void setCustomPointerColor ( final Color COLOR ) { getModel ( ) . setCustomPointerColorObject ( new CustomColorDef ( COLOR ) ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color from which the custom pointer color is calculated
|
40,311
|
public void setKnobType ( final KnobType KNOB_TYPE ) { getModel ( ) . setKnobType ( KNOB_TYPE ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the type of the knob
|
40,312
|
public void setKnobStyle ( final KnobStyle KNOB_STYLE ) { getModel ( ) . setKnobStyle ( KNOB_STYLE ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the the style of the center knob of a radial gauge
|
40,313
|
public void setLcdVisible ( final boolean LCD_VISIBLE ) { getModel ( ) . setLcdVisible ( LCD_VISIBLE ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Enables or disables the visibility of the lcd display
|
40,314
|
public void setGlowColor ( final Color GLOW_COLOR ) { getModel ( ) . setGlowColor ( GLOW_COLOR ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color that will be used for the glow indicator
|
40,315
|
public void setOuterFrameColor ( final Paint OUTER_FRAME_COLOR ) { FRAME_FACTORY . setOuterFrameColor ( OUTER_FRAME_COLOR ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color of the small outer frame of the gauge
|
40,316
|
public void setInnerFrameColor ( final Paint INNER_FRAME_COLOR ) { FRAME_FACTORY . setInnerFrameColor ( INNER_FRAME_COLOR ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color of the small inner frame of the gauge
|
40,317
|
public void setTicklabelOrientation ( final TicklabelOrientation TICKLABEL_ORIENTATION ) { getModel ( ) . setTicklabelOrienatation ( TICKLABEL_ORIENTATION ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the orientation of the tickmark labels
|
40,318
|
protected RadialGradientPaint createSection3DEffectGradient ( final int WIDTH , final float RADIUS_FACTOR ) { final float [ ] FRACTIONS ; final Color [ ] COLORS ; if ( isExpandedSectionsEnabled ( ) ) { FRACTIONS = new float [ ] { 0.0f , 0.7f , 0.75f , 0.96f , 1.0f } ; COLORS = new Color [ ] { new Color ( 0.0f , 0.0f , 0.0f , 1.0f ) , new Color ( 0.9f , 0.9f , 0.9f , 0.2f ) , new Color ( 1.0f , 1.0f , 1.0f , 0.5f ) , new Color ( 0.1843137255f , 0.1843137255f , 0.1843137255f , 0.3f ) , new Color ( 0.0f , 0.0f , 0.0f , 0.2f ) } ; } else { FRACTIONS = new float [ ] { 0.0f , 0.89f , 0.955f , 1.0f } ; COLORS = new Color [ ] { new Color ( 0.0f , 0.0f , 0.0f , 0.0f ) , new Color ( 0.0f , 0.0f , 0.0f , 0.3f ) , new Color ( 1.0f , 1.0f , 1.0f , 0.6f ) , new Color ( 0.0f , 0.0f , 0.0f , 0.4f ) } ; } final Point2D GRADIENT_CENTER = new Point2D . Double ( WIDTH / 2.0 , WIDTH / 2.0 ) ; return new RadialGradientPaint ( GRADIENT_CENTER , WIDTH * RADIUS_FACTOR , FRACTIONS , COLORS ) ; }
|
Returns a radial gradient paint that will be used as overlay for the track or section image to achieve some kind of a 3d effect .
|
40,319
|
protected RadialGradientPaint createArea3DEffectGradient ( final int WIDTH , final float RADIUS_FACTOR ) { final float [ ] FRACTIONS ; final Color [ ] COLORS ; FRACTIONS = new float [ ] { 0.0f , 0.6f , 1.0f } ; COLORS = new Color [ ] { new Color ( 1.0f , 1.0f , 1.0f , 0.75f ) , new Color ( 1.0f , 1.0f , 1.0f , 0.0f ) , new Color ( 0.0f , 0.0f , 0.0f , 0.3f ) } ; final Point2D GRADIENT_CENTER = new Point2D . Double ( WIDTH / 2.0 , WIDTH / 2.0 ) ; return new RadialGradientPaint ( GRADIENT_CENTER , WIDTH * RADIUS_FACTOR , FRACTIONS , COLORS ) ; }
|
Returns a radial gradient paint that will be used as overlay for the track or area image to achieve some kind of a 3d effect .
|
40,320
|
protected BufferedImage create_FRAME_Image ( final int WIDTH ) { switch ( getFrameType ( ) ) { case ROUND : return FRAME_FACTORY . createRadialFrame ( WIDTH , getFrameDesign ( ) , getCustomFrameDesign ( ) , getFrameBaseColor ( ) , isFrameBaseColorEnabled ( ) , getFrameEffect ( ) ) ; case SQUARE : return FRAME_FACTORY . createLinearFrame ( WIDTH , getFrameDesign ( ) , getCustomFrameDesign ( ) , getFrameBaseColor ( ) , isFrameBaseColorEnabled ( ) , getFrameEffect ( ) ) ; default : return FRAME_FACTORY . createRadialFrame ( WIDTH , getFrameDesign ( ) , getCustomFrameDesign ( ) , getFrameBaseColor ( ) , isFrameBaseColorEnabled ( ) , getFrameEffect ( ) ) ; } }
|
Returns the frame image with the currently active framedesign with the given width and the current frame type .
|
40,321
|
private BufferedImage create_KNOB_Image ( final int WIDTH , final KnobType KNOB_TYPE , final KnobStyle KNOB_STYLE ) { return KNOB_FACTORY . create_KNOB_Image ( WIDTH , KNOB_TYPE , KNOB_STYLE ) ; }
|
Creates a single alignment post image that could be placed on all the positions where it is needed
|
40,322
|
protected BufferedImage create_MEASURED_VALUE_Image ( final int WIDTH , final Color COLOR , final double ROTATION_OFFSET ) { if ( WIDTH <= 36 ) { return UTIL . createImage ( 1 , 1 , Transparency . TRANSLUCENT ) ; } final int IMAGE_HEIGHT = ( int ) ( WIDTH * 0.0280373832 ) ; final int IMAGE_WIDTH = IMAGE_HEIGHT ; 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 ) ; G2 . rotate ( ROTATION_OFFSET , IMAGE_WIDTH / 2.0 , IMAGE_HEIGHT / 2.0 ) ; final GeneralPath INDICATOR = new GeneralPath ( ) ; INDICATOR . setWindingRule ( Path2D . WIND_EVEN_ODD ) ; INDICATOR . moveTo ( IMAGE_WIDTH * 0.5 , IMAGE_HEIGHT ) ; INDICATOR . lineTo ( 0.0 , 0.0 ) ; INDICATOR . lineTo ( IMAGE_WIDTH , 0.0 ) ; INDICATOR . closePath ( ) ; G2 . setColor ( COLOR ) ; G2 . fill ( INDICATOR ) ; G2 . dispose ( ) ; return IMAGE ; }
|
Returns the image of the MinMeasuredValue and MaxMeasuredValue dependend
|
40,323
|
protected BufferedImage create_FOREGROUND_Image ( final int WIDTH ) { switch ( getFrameType ( ) ) { case ROUND : return FOREGROUND_FACTORY . createRadialForeground ( WIDTH ) ; case SQUARE : return FOREGROUND_FACTORY . createLinearForeground ( WIDTH , WIDTH ) ; default : return FOREGROUND_FACTORY . createRadialForeground ( WIDTH ) ; } }
|
Returns the image of the glasseffect with a centered knob
|
40,324
|
public void setPitch ( final double PITCH ) { this . pitch = PITCH % 180 ; if ( pitch > 90 ) { pitch = 90 - ( pitch - 90 ) ; if ( ! upsidedown ) { setRoll ( roll - 180 ) ; } upsidedown = true ; } else if ( pitch < - 90 ) { pitch = - 90 + ( - 90 - pitch ) ; if ( ! upsidedown ) { setRoll ( roll + 180 ) ; } upsidedown = true ; } else { upsidedown = false ; this . oldPitch = pitch ; } fireStateChanged ( ) ; repaint ( ) ; }
|
Sets the value of the current pitch
|
40,325
|
public void setCustomSkyColor ( final Color CUSTOM_SKY_COLOR ) { customSkyColor = CUSTOM_SKY_COLOR ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the custom color that will be used for visualization of the sky
|
40,326
|
public void setCustomGroundColor ( final Color CUSTOM_GROUND_COLOR ) { customGroundColor = CUSTOM_GROUND_COLOR ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the custom color that will be used for visualization of the ground
|
40,327
|
public void setOrientation ( final Orientation ORIENTATION ) { super . setOrientation ( ORIENTATION ) ; switch ( ORIENTATION ) { case NORTH : setLedPosition ( 0.455 , 0.51 ) ; setUserLedPosition ( 0.455 , 0.58 ) ; break ; case EAST : break ; case SOUTH : break ; case WEST : setLedPosition ( 0.455 , 0.51 ) ; setUserLedPosition ( 0.455 , 0.58 ) ; break ; default : setLedPosition ( 0.455 , 0.51 ) ; setUserLedPosition ( 0.455 , 0.58 ) ; break ; } init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the orientation of the gauge as an int value that is defined in javax . swing . SwingUtilities 1 = > NORTH = > Pointer rotation center placed on the bottom of the gauge 3 = > EAST = > Pointer rotation center placed on the left side of the gauge 5 = > SOUTH = > Pointer rotation center placed on the top of the gauge 7 = > WEST = > Pointer rotation center placed on the left side of the gauge
|
40,328
|
public void setSymbolType ( final SymbolType SYMBOL_TYPE ) { symbolType = SYMBOL_TYPE ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the type of symbol that will be drawn on the indicator
|
40,329
|
public void setOn ( final boolean ON ) { on = ON ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the symbol to on or off
|
40,330
|
public void setOnColor ( final ColorDef ON_COLOR ) { onColor = ON_COLOR ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color definition that is used to visualize the on state of the symbol
|
40,331
|
public void setCustomOnColor ( final CustomColorDef CUSTOM_ON_COLOR ) { customOnColor = CUSTOM_ON_COLOR ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the custom color definition that will be used to visualize the on state of the symbol
|
40,332
|
public void setOffColor ( final ColorDef OFF_COLOR ) { offColor = OFF_COLOR ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color definition that will be used to visualize the off state of the symbol
|
40,333
|
public void setCustomOffColor ( final CustomColorDef CUSTOM_OFF_COLOR ) { customOffColor = CUSTOM_OFF_COLOR ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the custom color definition that is used to visualize the off state of the symbol
|
40,334
|
public void setPointer2Color ( final ColorDef POINTER2_COLOR ) { pointer2Color = POINTER2_COLOR ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the colordefinition of the second pointer
|
40,335
|
public void setPointer2Type ( final PointerType POINTER2_TYPE ) { pointer2Type = POINTER2_TYPE ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the pointertype of the second pointer
|
40,336
|
public void setCustomPointer2Color ( final Color COLOR ) { this . customPointer2Color = new CustomColorDef ( COLOR ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the color from which the custom pointer2 color is calculated
|
40,337
|
protected BufferedImage create_BACKGROUND_Image ( final int WIDTH , final int HEIGHT , BufferedImage image ) { if ( WIDTH <= 0 || HEIGHT <= 0 ) { return UTIL . createImage ( 1 , 1 , Transparency . TRANSLUCENT ) ; } if ( image == null ) { image = UTIL . createImage ( WIDTH , HEIGHT , Transparency . TRANSLUCENT ) ; } final Graphics2D G2 = image . createGraphics ( ) ; G2 . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; G2 . setRenderingHint ( RenderingHints . KEY_STROKE_CONTROL , RenderingHints . VALUE_STROKE_NORMALIZE ) ; final int IMAGE_WIDTH = image . getWidth ( ) ; final int IMAGE_HEIGHT = image . getHeight ( ) ; BACKGROUND_FACTORY . createLinearBackground ( WIDTH , HEIGHT , getBackgroundColor ( ) , getModel ( ) . getCustomBackground ( ) , getModel ( ) . getTextureColor ( ) , image ) ; if ( isCustomLayerVisible ( ) ) { G2 . drawImage ( UTIL . getScaledInstance ( getCustomLayer ( ) , IMAGE_WIDTH , IMAGE_HEIGHT , RenderingHints . VALUE_INTERPOLATION_BICUBIC ) , 0 , 0 , null ) ; } G2 . dispose ( ) ; return image ; }
|
Returns the background image with the currently active backgroundcolor with the given width and height .
|
40,338
|
protected BufferedImage create_MEASURED_VALUE_Image ( final int WIDTH , final int HEIGHT , final Color COLOR ) { 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.05 ) ; IMAGE_HEIGHT = IMAGE_WIDTH ; } else { IMAGE_HEIGHT = ( int ) ( HEIGHT * 0.05 ) ; IMAGE_WIDTH = IMAGE_HEIGHT ; } 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 GeneralPath INDICATOR = new GeneralPath ( ) ; INDICATOR . setWindingRule ( Path2D . WIND_EVEN_ODD ) ; if ( getOrientation ( ) == Orientation . VERTICAL ) { INDICATOR . moveTo ( IMAGE_WIDTH , IMAGE_HEIGHT * 0.5 ) ; INDICATOR . lineTo ( 0.0 , 0.0 ) ; INDICATOR . lineTo ( 0.0 , IMAGE_HEIGHT ) ; INDICATOR . closePath ( ) ; } else { INDICATOR . moveTo ( IMAGE_WIDTH * 0.5 , 0.0 ) ; INDICATOR . lineTo ( IMAGE_WIDTH , IMAGE_HEIGHT ) ; INDICATOR . lineTo ( 0.0 , IMAGE_HEIGHT ) ; INDICATOR . closePath ( ) ; } G2 . setColor ( COLOR ) ; G2 . fill ( INDICATOR ) ; G2 . dispose ( ) ; return IMAGE ; }
|
Returns the image of the MinMeasuredValue and MaxMeasuredValue dependend on the given color
|
40,339
|
private void init ( final int WIDTH , final int HEIGHT ) { if ( WIDTH <= 1 || HEIGHT <= 1 ) { return ; } final double CORNER_RADIUS = WIDTH > HEIGHT ? ( HEIGHT * 0.095 ) : ( WIDTH * 0.095 ) ; if ( recreateImages ) { if ( sparkLineBackgroundImage != null ) { sparkLineBackgroundImage . flush ( ) ; } sparkLineBackgroundImage = create_SPARK_LINE_BACKGROUND_Image ( WIDTH , HEIGHT ) ; CLIP_SHAPE . setRoundRect ( 1 , 1 , WIDTH - 2 , HEIGHT - 2 , CORNER_RADIUS - 1 , CORNER_RADIUS - 1 ) ; if ( startIndicatorImage != null ) { startIndicatorImage . flush ( ) ; } startIndicatorImage = create_START_STOP_INDICATOR_Image ( WIDTH ) ; if ( stopIndicatorImage != null ) { stopIndicatorImage . flush ( ) ; } stopIndicatorImage = create_START_STOP_INDICATOR_Image ( WIDTH ) ; if ( loIndicatorImage != null ) { loIndicatorImage . flush ( ) ; } loIndicatorImage = create_LO_INDICATOR_Image ( WIDTH ) ; if ( hiIndicatorImage != null ) { hiIndicatorImage . flush ( ) ; } hiIndicatorImage = create_HI_INDICATOR_Image ( WIDTH ) ; } recreateImages = false ; disabledShape = new java . awt . geom . RoundRectangle2D . Double ( 0 , 0 , WIDTH , HEIGHT , CORNER_RADIUS , CORNER_RADIUS ) ; pixelResolution = INNER_BOUNDS . getWidth ( ) / ( double ) timeFrame ; offset = ( int ) ( 0.06 * WIDTH ) < 8 ? 8 : ( int ) ( 0.06 * WIDTH ) ; baseLineY = INNER_BOUNDS . y + INNER_BOUNDS . height - ( ( 0 - lo ) * ( 1 / scaleY ) + offset ) ; if ( ! DATA_LIST . isEmpty ( ) ) { calculate ( WIDTH , HEIGHT ) ; } if ( sparkLineImage != null ) { sparkLineImage . flush ( ) ; } sparkLineImage = createSparkLineImage ( WIDTH , HEIGHT ) ; }
|
Initializes the sparkline component with the given width and height
|
40,340
|
public void addDataPoint ( final double DATA ) { for ( DataPoint dataPoint : DATA_LIST ) { if ( System . currentTimeMillis ( ) - dataPoint . getTimeStamp ( ) > timeFrame ) { trashList . add ( dataPoint ) ; } } for ( DataPoint dataPoint : trashList ) { DATA_LIST . remove ( dataPoint ) ; } trashList . clear ( ) ; DATA_LIST . add ( new DataPoint ( System . currentTimeMillis ( ) , DATA ) ) ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Adds a new value to the DATA_LIST of the sparkline
|
40,341
|
public List < DataPoint > getDataList ( ) { List < DataPoint > dataListCopy = new LinkedList < eu . hansolo . steelseries . tools . DataPoint > ( ) ; dataListCopy . addAll ( DATA_LIST ) ; return dataListCopy ; }
|
Returns the linked list that contains the current data of the sparkline
|
40,342
|
public void setDataList ( LinkedList < DataPoint > dataList ) { DATA_LIST . clear ( ) ; DATA_LIST . addAll ( dataList ) ; repaint ( INNER_BOUNDS ) ; }
|
Clears the existing DATA_LIST and adds all elements from the given LinkedList to it
|
40,343
|
public double getVariance ( ) { if ( ! DATA_LIST . isEmpty ( ) ) { double sum = 0 ; double sumOfSquares = 0 ; double average = 0 ; for ( DataPoint dataPoint : DATA_LIST ) { sumOfSquares += ( dataPoint . getValue ( ) * dataPoint . getValue ( ) ) ; sum += dataPoint . getValue ( ) ; } average = sum / DATA_LIST . size ( ) ; return ( sumOfSquares / DATA_LIST . size ( ) ) - average * average ; } return 0 ; }
|
Returns the calculated varianz of the current data
|
40,344
|
public double getAverage ( ) { if ( ! DATA_LIST . isEmpty ( ) ) { double sum = 0 ; for ( DataPoint dataPoint : DATA_LIST ) { sum += dataPoint . getValue ( ) ; } return sum / DATA_LIST . size ( ) ; } return 0 ; }
|
Returns the calculated average of the current data
|
40,345
|
public double getMedian ( ) { if ( DATA_LIST . size ( ) > 2 ) { sortData ( ) ; if ( sortedList . size ( ) % 2 != 0 ) { return sortedList . get ( ( sortedList . size ( ) / 2 ) ) ; } else { return ( sortedList . get ( sortedList . size ( ) / 2 - 1 ) + sortedList . get ( sortedList . size ( ) / 2 ) ) / 2.0 ; } } return 0 ; }
|
Returns the median of the measured values
|
40,346
|
public void setTimeFrame ( final long TIME_FRAME ) { this . timeFrame = TIME_FRAME ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Defines the current timeframe of the sparkline in milliseconds
|
40,347
|
public void setFilled ( final boolean FILLED ) { this . filled = FILLED ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Enables or disables the filling of the area below the sparkline
|
40,348
|
public void setSmoothing ( final boolean SMOOTHING ) { this . smoothing = SMOOTHING ; if ( SMOOTHING ) { hiLoIndicatorVisible = false ; } init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Enables or disables the smoothing of the POINT_LIST and so of the sparkline
|
40,349
|
public void setSparkLineColor ( final LcdColor LCD_COLOR ) { this . lineColor = LCD_COLOR . TEXT_COLOR ; this . sparkLineColor = LCD_COLOR ; recreateImages = true ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Sets the color theme for the sparkline .
|
40,350
|
public void setLineColor ( final Color LINE_COLOR ) { this . lineColor = LINE_COLOR ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Sets the color of the sparkline
|
40,351
|
public void setAreaFill ( final ColorDef AREA_FILL_COLOR ) { this . areaFill = AREA_FILL_COLOR ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Sets the colordefinition of the area below the sparkline
|
40,352
|
public void setCustomAreaFillTop ( final Color CUSTOM_AREA_FILL_COLOR_TOP ) { customAreaFillTop = CUSTOM_AREA_FILL_COLOR_TOP ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Sets the color that will be used for a custom area gradient at top
|
40,353
|
public void setCustomAreaFillBottom ( final Color CUSTOM_AREA_FILL_COLOR_BOTTOM ) { customAreaFillBottom = CUSTOM_AREA_FILL_COLOR_BOTTOM ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Sets the color that will be used for a custom area gradient at bottom
|
40,354
|
public void setLineWidth ( final float LINE_WIDTH ) { lineWidth = LINE_WIDTH ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Defines the width of the sparkline
|
40,355
|
public void setLineShadow ( final boolean LINE_SHADOW_VISIBLE ) { lineShadowVisible = LINE_SHADOW_VISIBLE ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Enables or disables the visibility of the sparkline shadow
|
40,356
|
public void setSmoothFunction ( final SmoothingFunction SMOOTHING_FUNCTION ) { this . smoothFunction = SMOOTHING_FUNCTION ; init ( INNER_BOUNDS . width , INNER_BOUNDS . height ) ; repaint ( INNER_BOUNDS ) ; }
|
Defines the smoothing function that will be applied to the data if selected
|
40,357
|
private void calculate ( final int WIDTH , final int HEIGHT ) { start = DATA_LIST . getFirst ( ) . getValue ( ) ; stop = DATA_LIST . getLast ( ) . getValue ( ) ; lo = DATA_LIST . getFirst ( ) . getValue ( ) ; hi = DATA_LIST . getFirst ( ) . getValue ( ) ; loIndex = 0 ; hiIndex = 0 ; final int SIZE = DATA_LIST . size ( ) ; double y ; for ( int index = 0 ; index < SIZE ; index ++ ) { y = DATA_LIST . get ( index ) . getValue ( ) ; calcHiLoValues ( y , index ) ; } rangeY = hi - lo ; scaleY = rangeY / ( ( double ) HEIGHT - ( offset * 2 ) ) ; pointList . clear ( ) ; if ( DATA_LIST . size ( ) > 5 && smoothing ) { smoothData ( ) ; } else { for ( int index = 0 ; index < SIZE ; index ++ ) { pointList . add ( new Point2D . Double ( ( DATA_LIST . get ( index ) . getTimeStamp ( ) - DATA_LIST . getFirst ( ) . getTimeStamp ( ) ) * pixelResolution , ( ( DATA_LIST . get ( index ) . getValue ( ) - lo ) * ( 1 / scaleY ) + offset ) ) ) ; } } if ( averageVisible || normalAreaVisible ) { final double AVERAGE = ( getAverage ( ) - lo ) * ( 1 / scaleY ) + offset ; final double STANDARD_DEVIATION = ( getStandardDeviation ( ) * ( 1 / scaleY ) ) ; NORMAL_AREA . setRect ( INNER_BOUNDS . x , AVERAGE - STANDARD_DEVIATION , INNER_BOUNDS . width , 2 * STANDARD_DEVIATION ) ; AVERAGE_LINE . setLine ( INNER_BOUNDS . x , AVERAGE , INNER_BOUNDS . x + INNER_BOUNDS . width , AVERAGE ) ; } }
|
Calculates the sparkline with all it s parameters . This methods will be called everytime a new value was added to the DATA_LIST
|
40,358
|
private void calcHiLoValues ( double y , int index ) { if ( y < lo ) { lo = y ; loIndex = index ; } if ( y > hi ) { hi = y ; hiIndex = index ; } }
|
Calculates the max and min measured values and stores the index of the related values in in loIndex and hiIndex .
|
40,359
|
private void sortData ( ) { sortedList . clear ( ) ; for ( DataPoint dataPoint : DATA_LIST ) { sortedList . add ( dataPoint . getValue ( ) ) ; } Collections . sort ( sortedList ) ; }
|
Puts all values in a ArrayList and sorts them
|
40,360
|
private double continuousAverage ( final double Y0 , final double Y1 , final double Y2 ) { final double A = 1 ; final double B = 1 ; final double C = 1 ; return ( ( A * Y0 ) + ( B * Y1 ) + ( C * Y2 ) ) / ( A + B + C ) ; }
|
Returns the value smoothed by a continuous average function
|
40,361
|
private double cubicInterpolate ( final double Y0 , final double Y1 , final double Y2 , final double Y3 , final double MU ) { final double A0 ; final double A1 ; final double A2 ; final double A3 ; final double MU2 ; MU2 = MU * MU ; A0 = Y3 - Y2 - Y0 + Y1 ; A1 = Y0 - Y1 - A0 ; A2 = Y2 - Y0 ; A3 = Y1 ; return ( ( A0 * MU * MU2 ) + ( A1 * MU2 ) + ( A2 * MU ) + A3 ) ; }
|
Returns the value smoothed by a cubic spline interpolation function
|
40,362
|
private double cosInterpolate ( final double Y1 , final double Y2 , final double MU ) { final double MU2 ; MU2 = ( 1 - Math . cos ( MU * Math . PI ) ) / 2 ; return ( Y1 * ( 1 - MU2 ) + Y2 * MU2 ) ; }
|
Returns the value smoothed by a cosinus interpolation function
|
40,363
|
private double hermiteInterpolate ( final double Y0 , final double Y1 , final double Y2 , final double Y3 , final double MU , final double TENSION , final double BIAS ) { double m0 ; double m1 ; final double MU2 ; final double Mu3 ; final double A0 ; final double A1 ; final double A2 ; final double A3 ; MU2 = MU * MU ; Mu3 = MU2 * MU ; m0 = ( Y1 - Y0 ) * ( 1 + BIAS ) * ( 1 - TENSION ) / 2 ; m0 += ( Y2 - Y1 ) * ( 1 - BIAS ) * ( 1 - TENSION ) / 2 ; m1 = ( Y2 - Y1 ) * ( 1 + BIAS ) * ( 1 - TENSION ) / 2 ; m1 += ( Y3 - Y2 ) * ( 1 - BIAS ) * ( 1 - TENSION ) / 2 ; A0 = ( 2 * Mu3 ) - ( 3 * MU2 ) + 1 ; A1 = Mu3 - ( 2 * MU2 ) + MU ; A2 = Mu3 - MU2 ; A3 = ( - 2 * Mu3 ) + ( 3 * MU2 ) ; return ( ( A0 * Y1 ) + ( A1 * m0 ) + ( A2 * m1 ) + ( A3 * Y2 ) ) ; }
|
Returns the value smoothed by a hermite interpolation function
|
40,364
|
private BufferedImage create_HI_INDICATOR_Image ( final int WIDTH ) { if ( WIDTH <= 0 ) { return null ; } int indicatorSize = ( int ) ( 0.015 * WIDTH ) ; if ( indicatorSize < 4 ) { indicatorSize = 4 ; } if ( indicatorSize > 8 ) { indicatorSize = 8 ; } final BufferedImage IMAGE = UTIL . createImage ( indicatorSize , indicatorSize , Transparency . TRANSLUCENT ) ; final Graphics2D G2 = IMAGE . createGraphics ( ) ; G2 . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; G2 . setRenderingHint ( RenderingHints . KEY_RENDERING , RenderingHints . VALUE_RENDER_QUALITY ) ; G2 . setRenderingHint ( RenderingHints . KEY_DITHERING , RenderingHints . VALUE_DITHER_ENABLE ) ; G2 . setRenderingHint ( RenderingHints . KEY_ALPHA_INTERPOLATION , RenderingHints . VALUE_ALPHA_INTERPOLATION_QUALITY ) ; G2 . setRenderingHint ( RenderingHints . KEY_COLOR_RENDERING , RenderingHints . VALUE_COLOR_RENDER_QUALITY ) ; G2 . setRenderingHint ( RenderingHints . KEY_STROKE_CONTROL , RenderingHints . VALUE_STROKE_NORMALIZE ) ; G2 . setRenderingHint ( RenderingHints . KEY_TEXT_ANTIALIASING , RenderingHints . VALUE_TEXT_ANTIALIAS_ON ) ; final int IMAGE_WIDTH = IMAGE . getWidth ( ) ; final int IMAGE_HEIGHT = IMAGE . getHeight ( ) ; final GeneralPath THRESHOLD_TRIANGLE = new GeneralPath ( ) ; THRESHOLD_TRIANGLE . setWindingRule ( Path2D . WIND_EVEN_ODD ) ; THRESHOLD_TRIANGLE . moveTo ( IMAGE_WIDTH * 0.5 , 0 ) ; THRESHOLD_TRIANGLE . lineTo ( 0 , IMAGE_HEIGHT ) ; THRESHOLD_TRIANGLE . lineTo ( IMAGE_WIDTH , IMAGE_HEIGHT ) ; THRESHOLD_TRIANGLE . lineTo ( IMAGE_WIDTH * 0.5 , 0 ) ; THRESHOLD_TRIANGLE . closePath ( ) ; final Point2D THRESHOLD_TRIANGLE_START = new Point2D . Double ( 0 , THRESHOLD_TRIANGLE . getBounds2D ( ) . getMinY ( ) ) ; final Point2D THRESHOLD_TRIANGLE_STOP = new Point2D . Double ( 0 , THRESHOLD_TRIANGLE . getBounds2D ( ) . getMaxY ( ) ) ; final float [ ] THRESHOLD_TRIANGLE_FRACTIONS = { 0.0f , 0.3f , 0.59f , 1.0f } ; final Color [ ] THRESHOLD_TRIANGLE_COLORS = { new Color ( 82 , 0 , 0 , 255 ) , new Color ( 252 , 29 , 0 , 255 ) , new Color ( 252 , 29 , 0 , 255 ) , new Color ( 82 , 0 , 0 , 255 ) } ; final LinearGradientPaint THRESHOLD_TRIANGLE_GRADIENT = new LinearGradientPaint ( THRESHOLD_TRIANGLE_START , THRESHOLD_TRIANGLE_STOP , THRESHOLD_TRIANGLE_FRACTIONS , THRESHOLD_TRIANGLE_COLORS ) ; G2 . setPaint ( THRESHOLD_TRIANGLE_GRADIENT ) ; G2 . fill ( THRESHOLD_TRIANGLE ) ; G2 . setColor ( Color . RED ) ; G2 . setStroke ( new BasicStroke ( 1.0f , BasicStroke . CAP_BUTT , BasicStroke . JOIN_MITER ) ) ; G2 . draw ( THRESHOLD_TRIANGLE ) ; G2 . dispose ( ) ; return IMAGE ; }
|
Returns a buffered image that contains the hi value indicator
|
40,365
|
public void setHour ( final int HOUR ) { hour = HOUR % 12 ; calculateAngles ( hour , minute , second ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the current hour of the clock
|
40,366
|
public void setMinute ( final int MINUTE ) { minute = MINUTE % 60 ; calculateAngles ( hour , minute , second ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the current minute of the clock
|
40,367
|
public void setSecond ( final int SECOND ) { second = SECOND % 60 ; calculateAngles ( hour , minute , second ) ; repaint ( getInnerBounds ( ) ) ; }
|
Sets the current second of the clock
|
40,368
|
public void setLocation ( final Point2D LOCATION ) { this . lon = LOCATION . getX ( ) ; this . lat = LOCATION . getY ( ) ; this . LOCATION . setLocation ( LOCATION ) ; this . LOCATION_XY . setLocation ( toXY ( this . lat , this . lon ) ) ; adjustDirection ( ) ; }
|
Sets the location of the poi by the given Point2D
|
40,369
|
public final void setLocation ( final double LAT , final double LON ) { this . lon = LON ; this . lat = LAT ; this . LOCATION . setLocation ( LON , LAT ) ; this . LOCATION_XY . setLocation ( toXY ( LAT , LON ) ) ; adjustDirection ( ) ; }
|
Sets the location of the poi by the given latitude and longitude values
|
40,370
|
public double distanceTo ( final double LAT , final double LON ) { final double EARTH_RADIUS = 6371000.0 ; return Math . abs ( Math . acos ( Math . sin ( Math . toRadians ( LAT ) ) * Math . sin ( Math . toRadians ( this . lat ) ) + Math . cos ( Math . toRadians ( LAT ) ) * Math . cos ( Math . toRadians ( this . lat ) ) * Math . cos ( Math . toRadians ( LON - this . lon ) ) ) * EARTH_RADIUS ) ; }
|
Returns the distance in meters of the poi to the coordinate defined by the given latitude and longitude . The calculation takes the earth radius into account .
|
40,371
|
public Point2D shiftTo ( final double DISTANCE , final double ANGLE ) { final double EARTH_RADIUS = 6371000.0 ; final double LON1 = Math . toRadians ( this . lon ) ; final double LAT1 = Math . toRadians ( this . lat ) ; final double LAT2 = Math . asin ( Math . sin ( LAT1 ) * Math . cos ( DISTANCE / EARTH_RADIUS ) + Math . cos ( LAT1 ) * Math . sin ( DISTANCE / EARTH_RADIUS ) * Math . cos ( Math . toRadians ( ANGLE ) ) ) ; final double LON2 = LON1 + Math . atan2 ( Math . sin ( Math . toRadians ( ANGLE ) ) * Math . sin ( DISTANCE / EARTH_RADIUS ) * Math . cos ( LAT1 ) , Math . cos ( DISTANCE / EARTH_RADIUS ) - Math . sin ( LAT1 ) * Math . sin ( LAT2 ) ) ; final double LON2_CORRECTED = ( LON2 + 3 * Math . PI ) % ( 2 * Math . PI ) - Math . PI ; setLocation ( Math . toDegrees ( LAT2 ) , Math . toDegrees ( LON2_CORRECTED ) ) ; return getLocation ( ) ; }
|
Moves the poi to the position defined by the given distance and angle
|
40,372
|
public final Point2D toXY ( final double LAT , final double LON ) { final double LATITUDE = ( LAT * ( - 1 ) ) + 90.0 ; final double LONGITUDE = LON + 180.0 ; final double X = Math . round ( LONGITUDE * ( WORLD_MAP . getWidth ( ) / 360 ) ) ; final double Y = Math . round ( LATITUDE * ( WORLD_MAP . getHeight ( ) / 180 ) ) ; return new java . awt . geom . Point2D . Double ( X , Y ) ; }
|
Converts the given latitude and longitude to x y values
|
40,373
|
private BufferedImage create_POI_Image ( final int WIDTH ) { if ( WIDTH <= 0 ) { return null ; } final java . awt . image . BufferedImage IMAGE = UTIL . createImage ( WIDTH , WIDTH , java . awt . Transparency . TRANSLUCENT ) ; final java . awt . Graphics2D G2 = IMAGE . createGraphics ( ) ; G2 . setRenderingHint ( java . awt . RenderingHints . KEY_ANTIALIASING , java . awt . RenderingHints . VALUE_ANTIALIAS_ON ) ; G2 . setRenderingHint ( java . awt . RenderingHints . KEY_STROKE_CONTROL , java . awt . RenderingHints . VALUE_STROKE_NORMALIZE ) ; final java . awt . geom . Ellipse2D BLIP = new java . awt . geom . Ellipse2D . Double ( 0 , 0 , WIDTH , WIDTH ) ; final java . awt . geom . Point2D CENTER = new java . awt . geom . Point2D . Double ( BLIP . getCenterX ( ) , BLIP . getCenterY ( ) ) ; final float [ ] FRACTIONS = { 0.0f , 1.0f } ; final Color [ ] COLORS = { new Color ( 1.0f , 1.0f , 1.0f , 0.9f ) , new Color ( 1.0f , 1.0f , 1.0f , 0.0f ) } ; final java . awt . RadialGradientPaint GRADIENT = new java . awt . RadialGradientPaint ( CENTER , ( int ) ( WIDTH / 2.0 ) , FRACTIONS , COLORS ) ; G2 . setPaint ( GRADIENT ) ; G2 . fill ( BLIP ) ; G2 . dispose ( ) ; return IMAGE ; }
|
Creates the image of the poi
|
40,374
|
public void setRange ( final double RANGE ) { this . range = RANGE ; checkForBlips ( ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( ) ; }
|
Sets the range of the radar in meters which means the distance from the center of the radar to it s outer circle
|
40,375
|
public void setMyLocation ( final double LON , final double LAT ) { this . MY_LOCATION . setLocation ( LON , LAT ) ; checkForBlips ( ) ; init ( getInnerBounds ( ) . width , getInnerBounds ( ) . height ) ; repaint ( ) ; }
|
Defines the position of the center of the radar by the given coordinates as latitude and longitude
|
40,376
|
public void addPoi ( final Poi BLIP ) { if ( pois . keySet ( ) . contains ( BLIP . getName ( ) ) ) { updatePoi ( BLIP . getName ( ) , BLIP . getLocation ( ) ) ; } else { pois . put ( BLIP . getName ( ) , BLIP ) ; } checkForBlips ( ) ; }
|
Adds a new point of interest to the list of poi s of the radar Keep in mind that only the poi s are visible as blips that are in the range of the radar .
|
40,377
|
public void removePoi ( Poi BLIP ) { if ( pois . keySet ( ) . contains ( BLIP . getName ( ) ) ) { pois . remove ( BLIP . getName ( ) ) ; checkForBlips ( ) ; } }
|
Removes a point of interest from the radar Keep in mind that only the poi s are visible as blips that are in the range of the radar .
|
40,378
|
public Poi getPoi ( final String NAME ) { final Poi POINT_OF_INTEREST ; if ( pois . keySet ( ) . contains ( NAME ) ) { POINT_OF_INTEREST = pois . get ( NAME ) ; } else { POINT_OF_INTEREST = null ; } return POINT_OF_INTEREST ; }
|
Returns the point of interest given by it s name Keep in mind that only the poi s are visible as blips that are in the range of the radar .
|
40,379
|
public void animate ( final boolean RUN ) { if ( isEnabled ( ) ) { if ( RUN ) { if ( timeline . getState ( ) != Timeline . TimelineState . PLAYING_FORWARD && timeline . getState ( ) != Timeline . TimelineState . SUSPENDED ) { timeline = new Timeline ( this ) ; timeline . addPropertyToInterpolate ( "rotationAngle" , this . rotationAngle , 2 * Math . PI ) ; timeline . setEase ( new org . pushingpixels . trident . ease . Linear ( ) ) ; timeline . setDuration ( ( long ) ( 5000 ) ) ; timeline . playLoop ( Timeline . RepeatBehavior . LOOP ) ; } else if ( timeline . getState ( ) == Timeline . TimelineState . SUSPENDED ) { timeline . resume ( ) ; } } else { timeline . suspend ( ) ; } } }
|
Animates the radar beam of the component . This has no effect on the functionality but is only eye candy .
|
40,380
|
private void checkForBlips ( ) { blips . clear ( ) ; for ( Poi poi : pois . values ( ) ) { if ( poi . distanceTo ( MY_LOCATION ) < this . range ) { if ( ! blips . keySet ( ) . contains ( poi . getName ( ) ) ) { blips . put ( poi . getName ( ) , poi ) ; } } } }
|
Checks for poi s in the range of the radar
|
40,381
|
public void setValue ( final int VALUE ) { value = VALUE < 0 ? 0 : ( VALUE > 100 ? 100 : VALUE ) ; init ( getWidth ( ) , getHeight ( ) ) ; repaint ( INNER_BOUNDS ) ; }
|
Sets the current charge of the battery as integer from 0 - 100
|
40,382
|
public void setLightPosition ( final Orientation LIGHT_POSITION ) { lightPosition = LIGHT_POSITION ; init ( getWidth ( ) , getHeight ( ) ) ; repaint ( INNER_BOUNDS ) ; }
|
Set the position of the light that affects the gradient of the battery frame
|
40,383
|
private void calcInnerBounds ( ) { final java . awt . Insets INSETS = getInsets ( ) ; INNER_BOUNDS . setBounds ( INSETS . left , INSETS . top , ( getWidth ( ) - INSETS . left - INSETS . right ) , ( getHeight ( ) - INSETS . top - INSETS . bottom ) ) ; }
|
Calculates the rectangle that specifies the area that is available for painting the gauge . This means that if the component has insets that are larger than 0 these will be taken into account .
|
40,384
|
public void init ( Partition partition ) { try { List < ServerAddress > addressList = new ArrayList < > ( ) ; for ( String s : ( List < String > ) ( ( DeepPartition ) partition ) . splitWrapper ( ) . getReplicas ( ) ) { addressList . add ( new ServerAddress ( s ) ) ; } List < MongoCredential > mongoCredentials = new ArrayList < > ( ) ; if ( mongoDeepJobConfig . getUsername ( ) != null && mongoDeepJobConfig . getPassword ( ) != null ) { MongoCredential credential = MongoCredential . createMongoCRCredential ( mongoDeepJobConfig . getUsername ( ) , mongoDeepJobConfig . getDatabase ( ) , mongoDeepJobConfig . getPassword ( ) . toCharArray ( ) ) ; mongoCredentials . add ( credential ) ; } mongoClient = new MongoClient ( addressList , mongoCredentials ) ; mongoClient . setReadPreference ( ReadPreference . valueOf ( mongoDeepJobConfig . getReadPreference ( ) ) ) ; db = mongoClient . getDB ( mongoDeepJobConfig . getDatabase ( ) ) ; collection = db . getCollection ( mongoDeepJobConfig . getCollection ( ) ) ; dbCursor = collection . find ( generateFilterQuery ( ( MongoPartition ) partition ) , mongoDeepJobConfig . getDBFields ( ) ) ; } catch ( UnknownHostException e ) { throw new DeepExtractorInitializationException ( e ) ; } }
|
Init void .
|
40,385
|
private DBObject createQueryPartition ( MongoPartition partition ) { QueryBuilder queryBuilderMin = QueryBuilder . start ( partition . getKey ( ) ) ; DBObject bsonObjectMin = queryBuilderMin . greaterThanEquals ( partition . splitWrapper ( ) . getStartToken ( ) ) . get ( ) ; QueryBuilder queryBuilderMax = QueryBuilder . start ( partition . getKey ( ) ) ; DBObject bsonObjectMax = queryBuilderMax . lessThan ( partition . splitWrapper ( ) . getEndToken ( ) ) . get ( ) ; QueryBuilder queryBuilder = QueryBuilder . start ( ) ; if ( partition . splitWrapper ( ) . getStartToken ( ) != null ) { queryBuilder . and ( bsonObjectMin ) ; } if ( partition . splitWrapper ( ) . getEndToken ( ) != null ) { queryBuilder . and ( bsonObjectMax ) ; } LOG . debug ( "mongodb query " + queryBuilder . get ( ) ) ; return queryBuilder . get ( ) ; }
|
Create query partition .
|
40,386
|
private DBObject generateFilterQuery ( MongoPartition partition ) { if ( mongoDeepJobConfig . getQuery ( ) != null ) { QueryBuilder queryBuilder = QueryBuilder . start ( ) ; queryBuilder . and ( createQueryPartition ( partition ) , mongoDeepJobConfig . getQuery ( ) ) ; LOG . debug ( "mongodb query " + queryBuilder . get ( ) ) ; return queryBuilder . get ( ) ; } return createQueryPartition ( partition ) ; }
|
Generate filter query .
|
40,387
|
private void validate ( ) { if ( host . isEmpty ( ) ) { throw new IllegalArgumentException ( "host cannot be null" ) ; } if ( catalog == null ) { throw new IllegalArgumentException ( "database cannot be null" ) ; } if ( table == null ) { throw new IllegalArgumentException ( "collection cannot be null" ) ; } concantHostPort ( ) ; }
|
validates connection parameters
|
40,388
|
public MongoDeepJobConfig < T > filterQuery ( Filter [ ] filters ) { if ( filters . length > 0 ) { List < BasicDBObject > list = new ArrayList < > ( ) ; QueryBuilder queryBuilder = QueryBuilder . start ( ) ; for ( int i = 0 ; i < filters . length ; i ++ ) { BasicDBObject bsonObject = new BasicDBObject ( ) ; Filter filter = filters [ i ] ; if ( filter . getFilterType ( ) . equals ( FilterType . EQ ) ) { bsonObject . put ( filter . getField ( ) , filter . getValue ( ) ) ; } else { bsonObject . put ( filter . getField ( ) , new BasicDBObject ( "$" . concat ( filter . getFilterType ( ) . getFilterTypeId ( ) . toLowerCase ( ) ) , filter . getValue ( ) ) ) ; } list . add ( bsonObject ) ; } queryBuilder . and ( list . toArray ( new BasicDBObject [ list . size ( ) ] ) ) ; filterQuery ( queryBuilder ) ; } return this ; }
|
Filter query .
|
40,389
|
public static < T extends IDeepType > ESDeepJobConfig < T > createES ( Class < T > entityClass ) { return new ESDeepJobConfig < > ( entityClass ) ; }
|
Creates a new entity - based ElasticSearch job configuration object .
|
40,390
|
public TableMetadata fetchTableMetadata ( ) { Metadata metadata = getSession ( ) . getCluster ( ) . getMetadata ( ) ; KeyspaceMetadata ksMetadata = metadata . getKeyspace ( quote ( this . catalog ) ) ; if ( ksMetadata != null ) { return ksMetadata . getTable ( quote ( this . table ) ) ; } else { return null ; } }
|
Fetches table metadata from the underlying datastore using DataStax java driver .
|
40,391
|
private void waitForNewTableMetadata ( ) { TableMetadata metadata ; int retries = 0 ; final int waitTime = 100 ; do { metadata = getSession ( ) . getCluster ( ) . getMetadata ( ) . getKeyspace ( this . catalog ) . getTable ( quote ( this . table ) ) ; if ( metadata != null ) { continue ; } LOG . warn ( String . format ( "Metadata for new table %s.%s NOT FOUND, waiting %d millis" , this . catalog , this . table , waitTime ) ) ; try { Thread . sleep ( waitTime ) ; } catch ( InterruptedException e ) { LOG . error ( "Sleep interrupted" , e ) ; } retries ++ ; if ( retries >= 10 ) { throw new DeepIOException ( "Cannot retrieve metadata for the newly created CF " ) ; } } while ( metadata == null ) ; }
|
waits until table metadata is not null
|
40,392
|
public void save ( Map < String , Object > row ) throws Exception { Tuple2 < List < String > , String > data = sqlFromRow ( row ) ; PreparedStatement statement = conn . prepareStatement ( data . _2 ( ) ) ; int i = 1 ; for ( String columnName : data . _1 ( ) ) { statement . setObject ( i , row . get ( columnName ) ) ; i ++ ; } statement . executeUpdate ( ) ; }
|
Saves data .
|
40,393
|
@ SuppressWarnings ( "unchecked" ) public static < T > T newTypeInstance ( String className , Class < T > returnClass ) { try { Class < T > clazz = ( Class < T > ) Class . forName ( className ) ; return clazz . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException | ClassNotFoundException e ) { throw new DeepGenericException ( e ) ; } }
|
Creates a new instance of the given class name .
|
40,394
|
public static String quote ( String identifier ) { if ( StringUtils . isEmpty ( identifier ) ) { return identifier ; } String res = identifier . trim ( ) ; if ( ! res . startsWith ( "\"" ) ) { res = "\"" + res ; } if ( ! res . endsWith ( "\"" ) ) { res = res + "\"" ; } return res ; }
|
Quoting for working with uppercase
|
40,395
|
public static String batchQueryGenerator ( List < String > statements ) { StringBuilder sb = new StringBuilder ( "BEGIN BATCH \n" ) ; for ( String statement : statements ) { sb . append ( statement ) . append ( "\n" ) ; } sb . append ( " APPLY BATCH;" ) ; return sb . toString ( ) ; }
|
Returns a CQL batch query wrapping the given statements .
|
40,396
|
public static Tuple2 < String [ ] , Object [ ] > prepareTuple4CqlDriver ( Tuple2 < Cells , Cells > tuple ) { Cells keys = tuple . _1 ( ) ; Cells columns = tuple . _2 ( ) ; String [ ] names = new String [ keys . size ( ) + columns . size ( ) ] ; Object [ ] values = new Object [ keys . size ( ) + columns . size ( ) ] ; for ( int k = 0 ; k < keys . size ( ) ; k ++ ) { Cell cell = keys . getCellByIdx ( k ) ; names [ k ] = quote ( cell . getCellName ( ) ) ; values [ k ] = cell . getCellValue ( ) ; } for ( int v = keys . size ( ) ; v < ( keys . size ( ) + columns . size ( ) ) ; v ++ ) { Cell cell = columns . getCellByIdx ( v - keys . size ( ) ) ; names [ v ] = quote ( cell . getCellName ( ) ) ; values [ v ] = cell . getCellValue ( ) ; } return new Tuple2 < > ( names , values ) ; }
|
Splits columns names and values as required by Datastax java driver to generate an Insert query .
|
40,397
|
@ SuppressWarnings ( "unchecked" ) public static Method findSetter ( String propertyName , Class entityClass , Class valueType ) { Method setter ; String setterName = "set" + propertyName . substring ( 0 , 1 ) . toUpperCase ( ) + propertyName . substring ( 1 ) ; try { setter = entityClass . getMethod ( setterName , valueType ) ; } catch ( NoSuchMethodException e ) { try { setter = entityClass . getMethod ( propertyName + "_$eq" , valueType ) ; } catch ( NoSuchMethodException e1 ) { throw new DeepIOException ( e1 ) ; } } return setter ; }
|
Resolves the setter name for the property whose name is propertyName whose type is valueType in the entity bean whose class is entityClass . If we don t find a setter following Java s naming conventions before throwing an exception we try to resolve the setter following Scala s naming conventions .
|
40,398
|
@ SuppressWarnings ( "unchecked" ) public static Method findGetter ( String propertyName , Class entityClass ) { Method getter ; String getterName = "get" + propertyName . substring ( 0 , 1 ) . toUpperCase ( ) + propertyName . substring ( 1 ) ; try { getter = entityClass . getMethod ( getterName ) ; } catch ( NoSuchMethodException e ) { try { getter = entityClass . getMethod ( propertyName + "_$eq" ) ; } catch ( NoSuchMethodException e1 ) { throw new DeepIOException ( e1 ) ; } } return getter ; }
|
Resolves the getter name for the property whose name is propertyName whose type is valueType in the entity bean whose class is entityClass . If we don t find a setter following Java s naming conventions before throwing an exception we try to resolve the setter following Scala s naming conventions .
|
40,399
|
public static InetAddress inetAddressFromLocation ( String location ) { try { return InetAddress . getByName ( location ) ; } catch ( UnknownHostException e ) { throw new DeepIOException ( e ) ; } }
|
Returns the inet address for the specified location .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.