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


Java GradientSlider类代码示例

本文整理汇总了Java中com.bric.swing.GradientSlider的典型用法代码示例。如果您正苦于以下问题:Java GradientSlider类的具体用法?Java GradientSlider怎么用?Java GradientSlider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createGradientSlider

import com.bric.swing.GradientSlider; //导入依赖的package包/类
private void createGradientSlider(float[] defaultThumbPositions, Color[] defaultColors) {
    gradientSlider = new GradientSlider(GradientSlider.HORIZONTAL, defaultThumbPositions, defaultColors);
    gradientSlider.addPropertyChangeListener(evt -> {
        if(shouldStartFilter(evt)) {
            adjustmentListener.paramAdjusted();
        }
    });
    gradientSlider.putClientProperty(GRADIENT_SLIDER_USE_BEVEL, "true");

    // if there other controls in the dialog, they will determine the horizontal size
    gradientSlider.setPreferredSize(new Dimension(250, 30));
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:13,代码来源:GradientParam.java

示例2: getIndex

import com.bric.swing.GradientSlider; //导入依赖的package包/类
private int getIndex(MouseEvent e) {
    int v;
    if (slider.getOrientation() == GradientSlider.HORIZONTAL) {
        v = e.getX();
        if (v < trackRect.x - getClickLocationTolerance() + 1 || v > trackRect.x + trackRect.width + getClickLocationTolerance() - 1) {
            return -1; // didn't click in the track;
        }
    } else {
        v = e.getY();
        if (v < trackRect.y - getClickLocationTolerance() + 1 || v > trackRect.y + trackRect.height + getClickLocationTolerance() - 1) {
            return -1;
        }
    }
    int min = Math.abs(v - thumbPositions[0]);
    int minIndex = 0;
    for (int a = 1; a < thumbPositions.length; a++) {
        int distance = Math.abs(v - thumbPositions[a]);
        if (distance < min) {
            min = distance;
            minIndex = a;
        }
    }
    if (min < getClickLocationTolerance()) {
        return minIndex;
    }
    return -1;
}
 
开发者ID:OSUCartography,项目名称:TerrainViewer,代码行数:28,代码来源:MultiThumbSliderUI.java

示例3: calculateGeometry

import com.bric.swing.GradientSlider; //导入依赖的package包/类
protected synchronized void calculateGeometry() {
    trackRect = calculateTrackRect();

    float[] pos = slider.getThumbPositions();

    if (thumbPositions.length != pos.length) {
        thumbPositions = new int[pos.length];
        thumbIndications = new float[pos.length];
    }
    if (slider.getOrientation() == GradientSlider.HORIZONTAL) {
        for (int a = 0; a < thumbPositions.length; a++) {
            if (slider.isInverted() == false) {
                thumbPositions[a] = trackRect.x + (int) (trackRect.width * pos[a]);
            } else {
                thumbPositions[a] = trackRect.x + (int) (trackRect.width * (1 - pos[a]));
            }
            thumbIndications[a] = 0;
        }
    } else {
        for (int a = 0; a < thumbPositions.length; a++) {
            if (slider.isInverted()) {
                thumbPositions[a] = trackRect.y + (int) (trackRect.height * pos[a]);
            } else {
                thumbPositions[a] = trackRect.y + (int) (trackRect.height * (1 - pos[a]));
            }
            thumbIndications[a] = 0;
        }
    }
}
 
开发者ID:OSUCartography,项目名称:TerrainViewer,代码行数:30,代码来源:MultiThumbSliderUI.java

示例4: nudge

import com.bric.swing.GradientSlider; //导入依赖的package包/类
private void nudge(int thumbIndex, int direction) {
    float pixelFraction;
    if (slider.getOrientation() == GradientSlider.HORIZONTAL) {
        pixelFraction = 1f / ((float) trackRect.width);
    } else {
        pixelFraction = 1f / ((float) trackRect.height);
    }
    if (direction < 0) {
        pixelFraction *= -1;
    }
    if (slider.isInverted()) {
        pixelFraction *= -1;
    }
    if (slider.getOrientation() == MultiThumbSlider.VERTICAL) {
        pixelFraction *= -1;
    }

    //repeat a couple of times: it's possible we'll nudge two values
    //so they're exactly equal, which will make validate() fail.
    //in that case: move the value ANOTHER nudge to the left/right
    //to really make a change.  But make sure we still respect the [0,1] limits.
    State state = new State();
    while (state.positions[thumbIndex] >= 0 && state.positions[thumbIndex] <= 1) {
        state.positions[thumbIndex] += pixelFraction;
        if (validatePositions(state)) {
            state.install();
            return;
        }
    }
}
 
开发者ID:OSUCartography,项目名称:TerrainViewer,代码行数:31,代码来源:MultiThumbSliderUI.java

示例5: getMinimumSize

import com.bric.swing.GradientSlider; //导入依赖的package包/类
public Dimension getMinimumSize(JComponent s) {
	Dimension d = super.getMinimumSize(s);
	if(slider.getOrientation()==GradientSlider.HORIZONTAL) {
		d.height+=2;
	} else {
		d.width+=2;
	}
	return d;
}
 
开发者ID:OSUCartography,项目名称:TerrainViewer,代码行数:10,代码来源:GradientSliderUI.java

示例6: getPreferredSize

import com.bric.swing.GradientSlider; //导入依赖的package包/类
public Dimension getPreferredSize(JComponent s) {
	Dimension d = super.getPreferredSize(s);
	if(slider.getOrientation()==GradientSlider.HORIZONTAL) {
		d.height+=2;
	} else {
		d.width+=2;
	}
	return d;
}
 
开发者ID:OSUCartography,项目名称:TerrainViewer,代码行数:10,代码来源:GradientSliderUI.java

示例7: calculateTrackRect

import com.bric.swing.GradientSlider; //导入依赖的package包/类
protected Rectangle calculateTrackRect() {
	int w = slider.getWidth();
	int h = slider.getHeight();
	
	Rectangle r = new Rectangle();
	
	if(slider.getOrientation()==GradientSlider.HORIZONTAL) {
		r.x = TRIANGLE_SIZE;
		r.y = 3;
		r.height = h-TRIANGLE_SIZE-r.y;
		r.width = w-2*TRIANGLE_SIZE;
		if(r.width>img.getWidth()) {
			r.width = img.getWidth();
			r.x = (w-2*TRIANGLE_SIZE)/2-r.width/2;
		}
		if(r.height>2*DEPTH) {
			r.height = 2*DEPTH;
			r.y = (h-TRIANGLE_SIZE)/2-r.height/2;
		}
	} else {
		r.x = 3;
		r.y = TRIANGLE_SIZE;
		r.width = w-TRIANGLE_SIZE-r.x;
		r.height = h-2*TRIANGLE_SIZE;
		if(r.height>img.getWidth()) {
			r.height = img.getWidth();
			r.y = (h-2*TRIANGLE_SIZE)/2-r.height/2;
		}
		if(r.width>2*DEPTH) {
			r.width = 2*DEPTH;
			r.x = (w-TRIANGLE_SIZE)/2-r.width/2;
		}
	}
	return r;
}
 
开发者ID:OSUCartography,项目名称:TerrainViewer,代码行数:36,代码来源:GradientSliderUI.java

示例8: GradientSliderUI

import com.bric.swing.GradientSlider; //导入依赖的package包/类
public GradientSliderUI(GradientSlider slider) {
	super(slider);
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:4,代码来源:GradientSliderUI.java

示例9: mouseDragged

import com.bric.swing.GradientSlider; //导入依赖的package包/类
public void mouseDragged(MouseEvent e) {
    if (slider.isEnabled() == false) {
        return;
    }

    e.translatePoint(dx, dy);

    mouseMoved(e);
    if (pressedState != null && pressedState.selectedThumb != -1) {
        slider.setValueIsAdjusting(true);

        State newState = new State(pressedState);
        float v;
        boolean outside;
        if (slider.getOrientation() == GradientSlider.HORIZONTAL) {
            v = ((float) (e.getX() - trackRect.x)) / ((float) trackRect.width);
            if (slider.isInverted()) {
                v = 1 - v;
            }
            outside = (e.getY() < trackRect.y - 10) || (e.getY() > trackRect.y + trackRect.height + 10);

            //don't whack the thumb off the slider if you happen to be *near* the edge:
            if (e.getX() > trackRect.x - 10 && e.getX() < trackRect.x + trackRect.width + 10) {
                if (v < 0) {
                    v = 0;
                }
                if (v > 1) {
                    v = 1;
                }
            }
        } else {
            v = ((float) (e.getY() - trackRect.y)) / ((float) trackRect.height);
            if (slider.isInverted() == false) {
                v = 1 - v;
            }
            outside = (e.getX() < trackRect.x - 10) || (e.getX() > trackRect.x + trackRect.width + 10);

            if (e.getY() > trackRect.y - 10 && e.getY() < trackRect.y + trackRect.height + 10) {
                if (v < 0) {
                    v = 0;
                }
                if (v > 1) {
                    v = 1;
                }
            }
        }
        if (newState.positions.length <= 2) {
            outside = false; //I don't care if you are outside: no removing!
        }
        
        newState.positions[newState.selectedThumb] = v;

        //because we delegate mouseReleased() to this method:
        if (outside) {
            newState.removeThumb(newState.selectedThumb);
        }
        if (validatePositions(newState)) {
            newState.install();
        }
        e.consume();
    }
}
 
开发者ID:OSUCartography,项目名称:TerrainViewer,代码行数:63,代码来源:MultiThumbSliderUI.java


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