当前位置: 首页>>代码示例>>Java>>正文


Java CycleMethod.REPEAT属性代码示例

本文整理汇总了Java中java.awt.MultipleGradientPaint.CycleMethod.REPEAT属性的典型用法代码示例。如果您正苦于以下问题:Java CycleMethod.REPEAT属性的具体用法?Java CycleMethod.REPEAT怎么用?Java CycleMethod.REPEAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.MultipleGradientPaint.CycleMethod的用法示例。


在下文中一共展示了CycleMethod.REPEAT属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isPaintValid

@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:D3DPaints.java

示例2: paintHighlight

@Override
public void paintHighlight(Graphics2D graphics, Component comp, int width,
		int height, SubstanceColorScheme colorScheme) {
	Graphics2D g2d = (Graphics2D) graphics.create();

	Color[] fillColors = new Color[this.fractions.length];
	for (int i = 0; i < this.fractions.length; i++) {
		fillColors[i] = this.colorQueries[i].query(colorScheme);
	}

	MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0,
			height, this.fractions, fillColors, CycleMethod.REPEAT);
	g2d.setPaint(gradient);
	g2d.fillRect(0, 0, width, height);
	g2d.dispose();
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:16,代码来源:FractionBasedHighlightPainter.java

示例3: paintContourBackground

@Override
public void paintContourBackground(Graphics g, Component comp, int width,
		int height, Shape contour, boolean isFocused,
		SubstanceColorScheme fillScheme, boolean hasShine) {
	Graphics2D graphics = (Graphics2D) g.create();

	Color[] fillColors = new Color[this.fractions.length];
	for (int i = 0; i < this.fractions.length; i++) {
		ColorSchemeSingleColorQuery colorQuery = this.colorQueries[i];
		fillColors[i] = colorQuery.query(fillScheme);
	}

	MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0,
			height, this.fractions, fillColors, CycleMethod.REPEAT);
	graphics.setPaint(gradient);
	graphics.fill(contour);
	graphics.dispose();
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:18,代码来源:FractionBasedFillPainter.java

示例4: isPaintValid

@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        // we can delegate to the optimized two-color gradient
        // codepath, which does not require fragment shader support
        return true;
    }

    return super.isPaintValid(sg2d);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:OGLPaints.java

示例5: paintDecoratedBackground

private void paintDecoratedBackground(Graphics2D graphics, Component comp,
		DecorationAreaType decorationAreaType, int width, int height,
		SubstanceColorScheme scheme) {
	Graphics2D g2d = (Graphics2D) graphics.create();
	Color[] fillColors = new Color[this.fractions.length];
	for (int i = 0; i < this.fractions.length; i++) {
		ColorSchemeSingleColorQuery colorQuery = this.colorQueries[i];
		fillColors[i] = colorQuery.query(scheme);
	}

	Component topMostWithSameDecorationAreaType = SubstancePainterUtils
			.getTopMostParentWithDecorationAreaType(comp,
					decorationAreaType);
	Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0),
			topMostWithSameDecorationAreaType);
	int dy = inTopMost.y;

	MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0,
			topMostWithSameDecorationAreaType.getHeight(), this.fractions,
			fillColors, CycleMethod.REPEAT);
	g2d.setPaint(gradient);
	g2d.translate(0, -dy);
	g2d
			.fillRect(0, 0, width, topMostWithSameDecorationAreaType
					.getHeight());

	g2d.dispose();
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:28,代码来源:FractionBasedDecorationPainter.java

示例6: paintExtraBackground

/**
 * Paints the background of non-title decoration areas.
 * 
 * @param graphics
 *            Graphics context.
 * @param parent
 *            Component ancestor for computing the correct offset of the
 *            background painting.
 * @param comp
 *            Component.
 * @param width
 *            Width.
 * @param height
 *            Height.
 * @param scheme
 *            Color scheme for painting the title background.
 */
private void paintExtraBackground(Graphics2D graphics, Container parent,
		Component comp, int width, int height, SubstanceColorScheme scheme) {
	Point offset = SubstancePainterUtils.getOffsetInRootPaneCoords(comp);
	JRootPane rootPane = SwingUtilities.getRootPane(parent);
	// fix for bug 234 - Window doesn't have a root pane.
	JComponent titlePane = null;
	if (rootPane != null) {
		titlePane = SubstanceCoreUtilities.getTitlePane(rootPane);
	}

	int pWidth = (titlePane == null) ? parent.getWidth() : titlePane
			.getWidth();

	if (pWidth != 0) {
		LinearGradientPaint gradientBottom = new LinearGradientPaint(
				-offset.x, 0, -offset.x + pWidth, 0, new float[] { 0.0f,
						0.5f, 1.0f }, new Color[] { scheme.getMidColor(),
						scheme.getLightColor(), scheme.getMidColor() },
				CycleMethod.REPEAT);
		Graphics2D g2d = (Graphics2D) graphics.create();
		g2d.setPaint(gradientBottom);
		g2d.fillRect(-offset.x, 0, pWidth, height);
		g2d.dispose();
	}

}
 
开发者ID:Depter,项目名称:JRLib,代码行数:43,代码来源:ArcDecorationPainter.java

示例7: indexIntoGradientsArrays

/**
 * Helper function to index into the gradients array.  This is necessary
 * because each interval has an array of colors with uniform size 255.
 * However, the color intervals are not necessarily of uniform length, so
 * a conversion is required.
 *
 * @param position the unmanipulated position, which will be mapped
 *                 into the range 0 to 1
 * @returns integer color to display
 */
protected final int indexIntoGradientsArrays(float position) {
    // first, manipulate position value depending on the cycle method
    if (cycleMethod == CycleMethod.NO_CYCLE) {
        if (position > 1) {
            // upper bound is 1
            position = 1;
        } else if (position < 0) {
            // lower bound is 0
            position = 0;
        }
    } else if (cycleMethod == CycleMethod.REPEAT) {
        // get the fractional part
        // (modulo behavior discards integer component)
        position = position - (int)position;

        //position should now be between -1 and 1
        if (position < 0) {
            // force it to be in the range 0-1
            position = position + 1;
        }
    } else { // cycleMethod == CycleMethod.REFLECT
        if (position < 0) {
            // take absolute value
            position = -position;
        }

        // get the integer part
        int part = (int)position;

        // get the fractional part
        position = position - part;

        if ((part & 1) == 1) {
            // integer part is odd, get reflected color instead
            position = 1 - position;
        }
    }

    // now, get the color based on this 0-1 position...

    if (isSimpleLookup) {
        // easy to compute: just scale index by array size
        return gradient[(int)(position * fastGradientArraySize)];
    } else {
        // more complicated computation, to save space

        // for all the gradient interval arrays
        for (int i = 0; i < gradients.length; i++) {
            if (position < fractions[i+1]) {
                // this is the array we want
                float delta = position - fractions[i];

                // this is the interval we want
                int index = (int)((delta / normalizedIntervals[i])
                                  * (GRADIENT_SIZE_INDEX));

                return gradients[i][index];
            }
        }
    }

    return gradients[gradients.length - 1][GRADIENT_SIZE_INDEX];
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:73,代码来源:MultipleGradientPaintContext.java

示例8: indexIntoGradientsArrays

/**
 * Helper function to index into the gradients array.  This is necessary
 * because each interval has an array of colors with uniform size 255.
 * However, the color intervals are not necessarily of uniform length, so
 * a conversion is required.
 *
 * @param position the unmanipulated position, which will be mapped
 *                 into the range 0 to 1
 * @return integer color to display
 */
protected final int indexIntoGradientsArrays(float position) {
    // first, manipulate position value depending on the cycle method
    if (cycleMethod == CycleMethod.NO_CYCLE) {
        if (position > 1) {
            // upper bound is 1
            position = 1;
        } else if (position < 0) {
            // lower bound is 0
            position = 0;
        }
    } else if (cycleMethod == CycleMethod.REPEAT) {
        // get the fractional part
        // (modulo behavior discards integer component)
        position = position - (int)position;

        //position should now be between -1 and 1
        if (position < 0) {
            // force it to be in the range 0-1
            position = position + 1;
        }
    } else { // cycleMethod == CycleMethod.REFLECT
        if (position < 0) {
            // take absolute value
            position = -position;
        }

        // get the integer part
        int part = (int)position;

        // get the fractional part
        position = position - part;

        if ((part & 1) == 1) {
            // integer part is odd, get reflected color instead
            position = 1 - position;
        }
    }

    // now, get the color based on this 0-1 position...

    if (isSimpleLookup) {
        // easy to compute: just scale index by array size
        return gradient[(int)(position * fastGradientArraySize)];
    } else {
        // more complicated computation, to save space

        // for all the gradient interval arrays
        for (int i = 0; i < gradients.length; i++) {
            if (position < fractions[i+1]) {
                // this is the array we want
                float delta = position - fractions[i];

                // this is the interval we want
                int index = (int)((delta / normalizedIntervals[i])
                                  * (GRADIENT_SIZE_INDEX));

                return gradients[i][index];
            }
        }
    }

    return gradients[gradients.length - 1][GRADIENT_SIZE_INDEX];
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:73,代码来源:MultipleGradientPaintContext.java

示例9: indexIntoGradientsArrays

/**
 * Helper function to index into the gradients array.  This is necessary
 * because each interval has an array of colors with uniform size 255.
 * However, the color intervals are not necessarily of uniform length, so
 * a conversion is required.
 *
 * @param position the unmanipulated position, which will be mapped
 *                 into the range 0 to 1
 * @returns integer color to display
 */
protected final int indexIntoGradientsArrays(float position) {       
    // first, manipulate position value depending on the cycle method
    if (cycleMethod == CycleMethod.NO_CYCLE) {
        if (position > 1) {
            // upper bound is 1
            position = 1;
        } else if (position < 0) {
            // lower bound is 0
            position = 0;
        }
    } else if (cycleMethod == CycleMethod.REPEAT) {
        // get the fractional part
        // (modulo behavior discards integer component)
        position = position - (int)position; 

        //position should now be between -1 and 1
        if (position < 0) {
            // force it to be in the range 0-1
            position = position + 1;
        }           
    } else { // cycleMethod == CycleMethod.REFLECT
        if (position < 0) {
            // take absolute value
            position = -position;
        }                      

        // get the integer part
        int part = (int)position;

        // get the fractional part
        position = position - part;

        if ((part & 1) == 1) {
            // integer part is odd, get reflected color instead
            position = 1 - position;
        }
    }
   
    // now, get the color based on this 0-1 position...

    if (isSimpleLookup) {
        // easy to compute: just scale index by array size
        return gradient[(int)(position * fastGradientArraySize)];
    } else {
        // more complicated computation, to save space
        
        // for all the gradient interval arrays
        for (int i = 0; i < gradients.length; i++) { 
            if (position < fractions[i+1]) {
                // this is the array we want
                float delta = position - fractions[i];        

                // this is the interval we want
                int index = (int)((delta / normalizedIntervals[i]) 
                                  * (GRADIENT_SIZE_INDEX));
                
                return gradients[i][index];
            }            
        }
    }
    
    return gradients[gradients.length - 1][GRADIENT_SIZE_INDEX];        
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:73,代码来源:MultipleGradientPaintContext.java

示例10: paintBorder

@Override
public void paintBorder(Graphics g, Component c, int width, int height,
		Shape contour, Shape innerContour, SubstanceColorScheme borderScheme) {
	if (contour == null)
		return;

	Graphics2D graphics = (Graphics2D) g.create();
	graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
			RenderingHints.VALUE_STROKE_NORMALIZE);

	Color[] drawColors = new Color[this.fractions.length];
	for (int i = 0; i < this.fractions.length; i++) {
		ColorSchemeSingleColorQuery colorQuery = this.colorQueries[i];
		drawColors[i] = colorQuery.query(borderScheme);
	}

	// System.out.println("\t" + interpolationScheme1.getDisplayName()
	// + " -> [" + cyclePos + "] "
	// + interpolationScheme2.getDisplayName());

	float strokeWidth = SubstanceSizeUtils
			.getBorderStrokeWidth(SubstanceSizeUtils
					.getComponentFontSize(c));
	// issue 433 - the "c" can be null when painting
	// the border of a tree icon used outside the
	// JTree context.
	boolean isSpecialButton = c instanceof SubstanceInternalArrowButton;
	int joinKind = isSpecialButton ? BasicStroke.JOIN_MITER
			: BasicStroke.JOIN_ROUND;
	int capKind = isSpecialButton ? BasicStroke.CAP_SQUARE
			: BasicStroke.CAP_BUTT;
	graphics.setStroke(new BasicStroke(strokeWidth, capKind, joinKind));

	MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0,
			height, this.fractions, drawColors, CycleMethod.REPEAT);
	graphics.setPaint(gradient);
	graphics.draw(contour);
	graphics.dispose();
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:41,代码来源:FractionBasedBorderPainter.java

示例11: paintBorder

@Override
public void paintBorder(Graphics g, Component c, int width, int height,
		Shape contour, Shape innerContour, SubstanceColorScheme borderScheme) {
	if (contour == null)
		return;

	Graphics2D graphics = (Graphics2D) g.create();
	graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
			RenderingHints.VALUE_STROKE_NORMALIZE);

	Color topBorderColor = getTopBorderColor(borderScheme);
	Color midBorderColor = getMidBorderColor(borderScheme);
	Color bottomBorderColor = getBottomBorderColor(borderScheme);

	if ((topBorderColor != null) && (midBorderColor != null)
			&& (bottomBorderColor != null)) {
		float strokeWidth = SubstanceSizeUtils
				.getBorderStrokeWidth(SubstanceSizeUtils
						.getComponentFontSize(c));
		// issue 433 - the "c" can be null when painting
		// the border of a tree icon used outside the
		// JTree context.
		boolean isSpecialButton = c instanceof SubstanceInternalArrowButton;
		int joinKind = isSpecialButton ? BasicStroke.JOIN_MITER
				: BasicStroke.JOIN_ROUND;
		int capKind = isSpecialButton ? BasicStroke.CAP_SQUARE
				: BasicStroke.CAP_BUTT;
		graphics.setStroke(new BasicStroke(strokeWidth, capKind, joinKind));

		MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0,
				height, new float[] { 0.0f, 0.5f, 1.0f },
				new Color[] { topBorderColor, midBorderColor,
						bottomBorderColor }, CycleMethod.REPEAT);
		graphics.setPaint(gradient);
		graphics.draw(contour);
	}

	graphics.dispose();
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:41,代码来源:StandardBorderPainter.java

示例12: paintBorder

@Override
public void paintBorder(Graphics g, Component c, int width, int height,
		Shape contour, Shape innerContour, SubstanceColorScheme borderScheme) {
	Graphics2D graphics = (Graphics2D) g.create();
	graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
			RenderingHints.VALUE_STROKE_NORMALIZE);

	// shift schemes
	SubstanceColorScheme scheme = getShiftScheme(borderScheme);

	float[] fractions = delegate.getFractions();
	ColorSchemeSingleColorQuery[] colorQueries = delegate.getColorQueries();
	Color[] fillColors = new Color[fractions.length];
	for (int i = 0; i < fractions.length; i++) {
		ColorSchemeSingleColorQuery colorQuery = colorQueries[i];
		Color color = colorQuery.query(scheme);
		// apply masks
		color = new Color(this.masks[i] & color.getRGB(), true);
		fillColors[i] = color;
	}

	float strokeWidth = SubstanceSizeUtils
			.getBorderStrokeWidth(SubstanceSizeUtils
					.getComponentFontSize(c));
	// issue 433 - the "c" can be null when painting
	// the border of a tree icon used outside the
	// JTree context.
	boolean isSpecialButton = c instanceof SubstanceInternalArrowButton;
	int joinKind = isSpecialButton ? BasicStroke.JOIN_MITER
			: BasicStroke.JOIN_ROUND;
	int capKind = isSpecialButton ? BasicStroke.CAP_SQUARE
			: BasicStroke.CAP_BUTT;
	graphics.setStroke(new BasicStroke(strokeWidth, capKind, joinKind));

	MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0,
			height, fractions, fillColors, CycleMethod.REPEAT);
	graphics.setPaint(gradient);
	graphics.draw(contour);
	graphics.dispose();
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:42,代码来源:DelegateFractionBasedBorderPainter.java

示例13: paintTitleBackground

/**
 * Paints the title background.
 * 
 * @param graphics
 *            Graphics context.
 * @param comp
 *            Component.
 * @param width
 *            Width.
 * @param height
 *            Height.
 * @param scheme
 *            Color scheme for painting the title background.
 */
private void paintTitleBackground(Graphics2D graphics, Component comp,
		int width, int height, SubstanceColorScheme scheme) {
	// System.out.println(scheme.getDisplayName());
	// create rectangular background and later draw it on
	// result image with contour clip.
	BufferedImage rectangular = SubstanceCoreUtilities.getBlankImage(width,
			height);
	Graphics2D rgraphics = (Graphics2D) rectangular.getGraphics();

	// Fill background
	GeneralPath clipTop = new GeneralPath();
	clipTop.moveTo(0, 0);
	clipTop.lineTo(width, 0);
	clipTop.lineTo(width, height / 2);
	clipTop.quadTo(width / 2, height / 4, 0, height / 2);
	clipTop.lineTo(0, 0);

	rgraphics.setClip(clipTop);
	LinearGradientPaint gradientTop = new LinearGradientPaint(0, 0, width,
			0, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] {
					scheme.getLightColor(), scheme.getUltraLightColor(),
					scheme.getLightColor() }, CycleMethod.REPEAT);
	rgraphics.setPaint(gradientTop);
	rgraphics.fillRect(0, 0, width, height);

	GeneralPath clipBottom = new GeneralPath();
	clipBottom.moveTo(0, height);
	clipBottom.lineTo(width, height);
	clipBottom.lineTo(width, height / 2);
	clipBottom.quadTo(width / 2, height / 4, 0, height / 2);
	clipBottom.lineTo(0, height);

	rgraphics.setClip(clipBottom);
	LinearGradientPaint gradientBottom = new LinearGradientPaint(0, 0,
			width, 0, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] {
					scheme.getMidColor(), scheme.getLightColor(),
					scheme.getMidColor() }, CycleMethod.REPEAT);
	rgraphics.setPaint(gradientBottom);
	rgraphics.fillRect(0, 0, width, height);

	GeneralPath mid = new GeneralPath();
	mid.moveTo(width, height / 2);
	mid.quadTo(width / 2, height / 4, 0, height / 2);
	// rgraphics.setClip(new Rectangle(0, 0, width / 2, height));
	// rgraphics
	// .setClip(new Rectangle(width / 2, 0, width - width / 2, height));
	rgraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	rgraphics.setClip(new Rectangle(0, 0, width, height));
	rgraphics.draw(mid);

	graphics.drawImage(rectangular, 0, 0, null);
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:67,代码来源:ArcDecorationPainter.java


注:本文中的java.awt.MultipleGradientPaint.CycleMethod.REPEAT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。