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


Java Slider类代码示例

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


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

示例1: handleComponentUpdate

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
@Override
protected void handleComponentUpdate(Slider component) {
    if (component.isValueChanging()) {
        if (!Mouse.isButtonDown(0)) {
            component.setValueChanging(false);
            WurstClient.INSTANCE.files.saveNavigatorData();
            return;
        }
        Point mouse = RenderUtil.calculateMouseLocation();
        Container parent = component.getParent();
        if (parent != null) mouse.translate(-parent.getX(), -parent.getY());
        double percent = (double) (mouse.x - 4) / (double) (component.getWidth() - 6);
        double value =
                component.getMinimumValue() + percent * (component.getMaximumValue() - component.getMinimumValue());
        component.setValue(value);
    }
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:18,代码来源:WurstSliderUI.java

示例2: handleComponentUpdate

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
@Override
protected void handleComponentUpdate(Slider component) {
    if (component.isValueChanging()) {
        if (!Mouse.isButtonDown(0)) {
            component.setValueChanging(false);
            return;
        }
        Point mouse = RenderUtil.calculateMouseLocation();
        Container parent = component.getParent();
        if (parent != null) mouse.translate(-parent.getX(), -parent.getY());
        double percent = (double) mouse.x / (double) component.getWidth();
        double value =
                component.getMinimumValue() + percent * (component.getMaximumValue() - component.getMinimumValue());
        component.setValue(value);
    }
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:17,代码来源:SimpleSliderUI.java

示例3: WurstSliderUI

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
public WurstSliderUI(WurstTheme theme) {
    super(Slider.class);
    this.theme = theme;

    foreground = Color.WHITE;
    background = new Color(128, 128, 128, 128 + 128 / 2);
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:8,代码来源:WurstSliderUI.java

示例4: handleComponentInteraction

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
@Override
protected void handleComponentInteraction(Slider component, Point location, int button) {
    if (getInteractableComponentRegions(component)[0].contains(location) && button == 0) {
        if (Mouse.isButtonDown(button) && !component.isValueChanging()) {
            component.setValueChanging(true);
        } else if (!Mouse.isButtonDown(button) && component.isValueChanging()) component.setValueChanging(false);
    }
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:9,代码来源:WurstSliderUI.java

示例5: SimpleSliderUI

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
public SimpleSliderUI(SimpleTheme theme) {
    super(Slider.class);
    this.theme = theme;

    foreground = Color.LIGHT_GRAY;
    background = new Color(128, 128, 128, 128 + 128 / 2);
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:8,代码来源:SimpleSliderUI.java

示例6: getDefaultComponentSize

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
@Override
protected Dimension getDefaultComponentSize(Slider component) {
    return new Dimension(106, 8 + theme.getFontRenderer().FONT_HEIGHT);
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:5,代码来源:WurstSliderUI.java

示例7: getInteractableComponentRegions

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
@Override
protected Rectangle[] getInteractableComponentRegions(Slider component) {
    return new Rectangle[]{new Rectangle(0, theme.getFontRenderer().FONT_HEIGHT + 2, component.getWidth(),
            component.getHeight() - theme.getFontRenderer().FONT_HEIGHT)};
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:6,代码来源:WurstSliderUI.java

示例8: renderComponent

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
@Override
protected void renderComponent(Slider component) {
    translateComponent(component, false);
    glEnable(GL_BLEND);
    glDisable(GL_CULL_FACE);
    Rectangle area = component.getArea();
    int fontSize = theme.getFontRenderer().FONT_HEIGHT;
    FontRenderer fontRenderer = theme.getFontRenderer();
    fontRenderer.drawString(component.getText(), 0, 0, RenderUtil.toRGBA(component.getForegroundColor()));
    String content = null;
    switch (component.getValueDisplay()) {
        case DECIMAL:
            content = String.format("%,.3f", component.getValue());
            break;
        case INTEGER:
            content = String.format("%,d", Math.round(component.getValue()));
            break;
        case PERCENTAGE:
            int percent = (int) Math.round((component.getValue() - component.getMinimumValue()) /
                    (component.getMaximumValue() - component.getMinimumValue()) * 100D);
            content = String.format("%d%%", percent);
        default:
    }
    if (content != null) {
        String suffix = component.getContentSuffix();
        if (suffix != null && !suffix.trim().isEmpty()) content = content.concat(" ").concat(suffix);
        fontRenderer.drawString(content, component.getWidth() - fontRenderer.getStringWidth(content), 0,
                RenderUtil.toRGBA(component.getForegroundColor()));
    }
    glDisable(GL_TEXTURE_2D);

    RenderUtil.setColor(component.getBackgroundColor());
    glLineWidth(0.9f);
    glBegin(GL_LINE_LOOP);
    {
        glVertex2d(0, fontSize + 2D);
        glVertex2d(area.width, fontSize + 2D);
        glVertex2d(area.width, area.height);
        glVertex2d(0, area.height);
    }
    glEnd();

    double sliderPercentage = (component.getValue() - component.getMinimumValue()) /
            (component.getMaximumValue() - component.getMinimumValue());
    RenderUtil.setColor(component.getForegroundColor());
    glBegin(GL_QUADS);
    {
        glVertex2d(0, fontSize + 2D);
        glVertex2d(area.width * sliderPercentage, fontSize + 2D);
        glVertex2d(area.width * sliderPercentage, area.height);
        glVertex2d(0, area.height);
    }
    glEnd();

    glEnable(GL_TEXTURE_2D);
    translateComponent(component, true);
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:58,代码来源:SimpleSliderUI.java

示例9: getDefaultComponentSize

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
@Override
protected Dimension getDefaultComponentSize(Slider component) {
    return new Dimension(100, 8 + theme.getFontRenderer().FONT_HEIGHT);
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:5,代码来源:SimpleSliderUI.java

示例10: onSliderValueChanged

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
public void onSliderValueChanged(Slider slider); 
开发者ID:CheataClient,项目名称:CheataClientSrc,代码行数:2,代码来源:SliderListener.java

示例11: onSliderValueChanged

import org.darkstorm.minecraft.gui.component.Slider; //导入依赖的package包/类
void onSliderValueChanged(Slider slider); 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:2,代码来源:SliderListener.java


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