當前位置: 首頁>>代碼示例>>Java>>正文


Java MultipleGradientPaint.getFractions方法代碼示例

本文整理匯總了Java中org.apache.batik.ext.awt.MultipleGradientPaint.getFractions方法的典型用法代碼示例。如果您正苦於以下問題:Java MultipleGradientPaint.getFractions方法的具體用法?Java MultipleGradientPaint.getFractions怎麽用?Java MultipleGradientPaint.getFractions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.batik.ext.awt.MultipleGradientPaint的用法示例。


在下文中一共展示了MultipleGradientPaint.getFractions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toString

import org.apache.batik.ext.awt.MultipleGradientPaint; //導入方法依賴的package包/類
/**
 * Creates a string representation of a {@code MultipleGradientPaint}. This
 * string is used for debugging purposes. Its contents cannot be guaranteed
 * between releases.
 * 
 * @param paint
 *                the {@code paint} to create a string for
 * @return a string representing the supplied {@code paint}
 */
public static String toString(MultipleGradientPaint paint) {
    StringBuffer buffer = new StringBuffer();
    buffer.append(paint.getClass().getName());
    Color[] colors = paint.getColors();
    float[] values = paint.getFractions();
    buffer.append("[");
    for(int i=0; i<colors.length; i++) {
        buffer.append("#").append(Integer.toHexString(colors[i].getRGB()));
        buffer.append(":");
        buffer.append(values[i]);
        buffer.append(", ");
    }
    buffer.append("]");
    return buffer.toString();
}
 
開發者ID:sing-group,項目名稱:aibench-project,代碼行數:25,代碼來源:JXGradientChooser.java

示例2: setGradient

import org.apache.batik.ext.awt.MultipleGradientPaint; //導入方法依賴的package包/類
/**
 * Sets the gradient within this panel to the new gradient. This will delete
 * the old gradient all of it's settings, resetting the slider, gradient
 * type selection, and other gradient configuration options to match the
 * new gradient.
 *
 * @param mgrad The desired gradient.
 */
public void setGradient(MultipleGradientPaint mgrad) {
    if(gradient == mgrad) {
        return;
    }
    float[] fracts = mgrad.getFractions();
    Color[] colors = mgrad.getColors();

    if(!thumbsMoving) {
        // update the slider properly
        if(slider.getModel().getThumbCount() !=
                mgrad.getColors().length) {
            // removing all thumbs;
            while(slider.getModel().getThumbCount() > 0) {
                slider.getModel().removeThumb(0);
            }
            // add them back
            for(int i=0; i<fracts.length; i++) {
                slider.getModel().addThumb(fracts[i],colors[i]);
            }
        } else {
            for(int i=0; i<fracts.length; i++) {
                slider.getModel().getThumbAt(i).setObject(colors[i]);
                slider.getModel().getThumbAt(i).setPosition(fracts[i]);
            }
        }
    } else {
        log.fine("not updating because it's moving");
    }
    if(mgrad instanceof RadialGradientPaint) {
        if(styleCombo.getSelectedItem() != GradientStyle.Radial) {
            styleCombo.setSelectedItem(GradientStyle.Radial);
        }
    } else {
        if(styleCombo.getSelectedItem() != GradientStyle.Linear) {
            styleCombo.setSelectedItem(GradientStyle.Linear);
        }
    }
    
    if(mgrad.getCycleMethod() == MultipleGradientPaint.REFLECT) {
        this.reflectedRadio.setSelected(true);
        gradientPreview.setReflected(true);
    }
    if(mgrad.getCycleMethod() == MultipleGradientPaint.REPEAT) {
        this.repeatedRadio.setSelected(true);
        gradientPreview.setRepeated(true);
    }
    gradientPreview.setGradient(mgrad);
    //reflectedRadio.setSelected()
    MultipleGradientPaint old = this.getGradient();
    gradient = mgrad;
    firePropertyChange("gradient",old,getGradient());
    repaint();
}
 
開發者ID:sing-group,項目名稱:aibench-project,代碼行數:62,代碼來源:JXGradientChooser.java


注:本文中的org.apache.batik.ext.awt.MultipleGradientPaint.getFractions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。