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


Java ProgressBar.getArea方法代码示例

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


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

示例1: renderComponent

import org.darkstorm.minecraft.gui.component.ProgressBar; //导入方法依赖的package包/类
@Override
protected void renderComponent(ProgressBar component) {
	Rectangle area = component.getArea();
	int fontSize = theme.getFontRenderer().FONT_HEIGHT;
	FontRenderer fontRenderer = theme.getFontRenderer();

	translateComponent(component, false);
	glEnable(GL_BLEND);
	glDisable(GL_CULL_FACE);
	glDisable(GL_TEXTURE_2D);

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

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

	glEnable(GL_TEXTURE_2D);
	String content = null;
	switch(component.getValueDisplay()) {
	case DECIMAL:
		content = String.format("%,.3f", component.getValue());
		break;
	case INTEGER:
		content = String.format("%,d", Long.valueOf(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) {
		glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
		fontRenderer.drawString(content, component.getWidth() / 2 - fontRenderer.getStringWidth(content) / 2, component.getHeight() / 2 - fontSize / 2, RenderUtil.toRGBA(component.getForegroundColor()));
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}
	glEnable(GL_CULL_FACE);
	glDisable(GL_BLEND);
	translateComponent(component, true);
}
 
开发者ID:CheataClient,项目名称:CheataClientSrc,代码行数:57,代码来源:SimpleProgressBarUI.java

示例2: renderComponent

import org.darkstorm.minecraft.gui.component.ProgressBar; //导入方法依赖的package包/类
@Override
protected void renderComponent(ProgressBar component) {
    Rectangle area = component.getArea();
    int fontSize = theme.getFontRenderer().FONT_HEIGHT;
    FontRenderer fontRenderer = theme.getFontRenderer();

    translateComponent(component, false);
    glEnable(GL_BLEND);
    glDisable(GL_CULL_FACE);
    glDisable(GL_TEXTURE_2D);

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

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

    glEnable(GL_TEXTURE_2D);
    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) {
        glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
        fontRenderer.drawString(content, component.getWidth() / 2 - fontRenderer.getStringWidth(content) / 2,
                component.getHeight() / 2 - fontSize / 2, RenderUtil.toRGBA(component.getForegroundColor()));
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    }
    glEnable(GL_CULL_FACE);
    glDisable(GL_BLEND);
    translateComponent(component, true);
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:60,代码来源:WurstProgressBarUI.java


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