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


Java PGraphics.textAlign方法代碼示例

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


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

示例1: showTitle

import processing.core.PGraphics; //導入方法依賴的package包/類
/** 顯示選中的標記對應的城市名稱 */
public void showTitle(PGraphics pg, float x, float y)
{
	String name = getCity() + " " + getCountry() + " ";
	String pop = "Pop: " + getPopulation() + " Million";
	
	pg.pushStyle();
	
	pg.fill(255, 255, 255);
	pg.textSize(12);
	pg.rectMode(PConstants.CORNER);
	pg.rect(x, y-TRI_SIZE-39, Math.max(pg.textWidth(name), pg.textWidth(pop)) + 6, 39);
	pg.fill(0, 0, 0);
	pg.textAlign(PConstants.LEFT, PConstants.TOP);
	pg.text(name, x+3, y-TRI_SIZE-33);
	pg.text(pop, x+3, y - TRI_SIZE -18);
	
	pg.popStyle();
}
 
開發者ID:simontangbit,項目名稱:CourseCode,代碼行數:20,代碼來源:CityMarker.java

示例2: showTitle

import processing.core.PGraphics; //導入方法依賴的package包/類
/** Show the title of the earthquake if this marker is selected */
public void showTitle(PGraphics pg, float x, float y)
{
	String title = getTitle();
	pg.pushStyle();
	
	pg.rectMode(PConstants.CORNER);
	
	pg.stroke(110);
	pg.fill(255,255,255);
	pg.rect(x, y + 15, pg.textWidth(title) +6, 18, 5);
	
	pg.textAlign(PConstants.LEFT, PConstants.TOP);
	pg.fill(0);
	pg.text(title, x + 3 , y +18);
	
	
	pg.popStyle();
	
}
 
開發者ID:snavjivan,項目名稱:Earthquake-Tracker,代碼行數:21,代碼來源:EarthquakeMarker.java

示例3: showTitle

import processing.core.PGraphics; //導入方法依賴的package包/類
public void showTitle(PGraphics pg, float x, float y)
{
	String name = getCity() + " " + getCountry() + " ";
	String pop = "Pop: " + getPopulation() + " Million";
	
	pg.pushStyle();
	
	pg.fill(255, 255, 255);
	pg.textSize(12);
	pg.rectMode(PConstants.CORNER);
	pg.rect(x, y-TRI_SIZE-39, Math.max(pg.textWidth(name), pg.textWidth(pop)) + 6, 39);
	pg.fill(0, 0, 0);
	pg.textAlign(PConstants.LEFT, PConstants.TOP);
	pg.text(name, x+3, y-TRI_SIZE-33);
	pg.text(pop, x+3, y - TRI_SIZE -18);
	
	pg.popStyle();
}
 
開發者ID:snavjivan,項目名稱:Earthquake-Tracker,代碼行數:19,代碼來源:CityMarker.java

示例4: showTitle

import processing.core.PGraphics; //導入方法依賴的package包/類
/** Show the title of the city if this marker is selected */
public void showTitle(PGraphics pg, float x, float y)
{
	String name = getCity() + " " + getCountry() + " ";
	String pop = "Pop: " + getPopulation() + " Million";
	
	pg.pushStyle();
	
	pg.fill(255, 255, 255);
	pg.textSize(12);
	pg.rectMode(PConstants.CORNER);
	pg.rect(x, y-TRI_SIZE-39, Math.max(pg.textWidth(name), pg.textWidth(pop)) + 6, 39);
	pg.fill(0, 0, 0);
	pg.textAlign(PConstants.LEFT, PConstants.TOP);
	pg.text(name, x+3, y-TRI_SIZE-33);
	pg.text(pop, x+3, y - TRI_SIZE -18);
	
	pg.popStyle();
}
 
開發者ID:imranalidigi,項目名稱:UCSDUnfoldingMapsMaven,代碼行數:20,代碼來源:CityMarker.java

示例5: showTitle

import processing.core.PGraphics; //導入方法依賴的package包/類
public void showTitle(PGraphics pg, float x, float y) {
	 // show rectangle with title
	// show routes
	
	String id = "ID : " + getId();
	String name = getName();
	
	pg.pushStyle();
	pg.fill(255,255,255);
	pg.textSize(12);
	pg.rectMode(PConstants.CORNER);
	pg.rect(x,y-8*radius,Math.max(pg.textWidth(id),pg.textWidth(name))+6,8*radius);
	pg.fill(0,0,0);
	pg.textAlign(PConstants.LEFT,PConstants.TOP);
	pg.text(id,x+3,y-7*radius);
	pg.text(name,x+3,y-4*radius);
	
	pg.popStyle();
}
 
開發者ID:prachi1210,項目名稱:air-travel-tracker,代碼行數:20,代碼來源:AirportMarker.java

示例6: checkbox

import processing.core.PGraphics; //導入方法依賴的package包/類
static boolean checkbox(PGraphics gx, float left, float top, boolean checked)
{
	boolean bClicked = false;
	
	if (m_MouseState.clickedInside(MouseState.LEFT, left, top, CHECKBOX_SIZE, CHECKBOX_SIZE)) {
		bClicked = true;
		checked = !checked;
	}
	
	gx.pushStyle();
	try{
		gx.fill(255);
		gx.stroke(m_MouseState.isStartIn(left, top, CHECKBOX_SIZE, CHECKBOX_SIZE) &&
				  m_MouseState.isIn(left, top, CHECKBOX_SIZE, CHECKBOX_SIZE) ? 0xFFFF0000 : 0);
		gx.rect(left, top, CHECKBOX_SIZE, CHECKBOX_SIZE);
		gx.fill(0);
		if (checked)
		{
			gx.textFont(dp.fontGuiFx);
			gx.textSize(CHECKBOX_SIZE);
			gx.textAlign(PConstants.CENTER, PConstants.CENTER);
			gx.text("z", left + CHECKBOX_SIZE/2, top + CHECKBOX_SIZE/2);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	gx.popStyle();
	return bClicked;
}
 
開發者ID:hyounesy,項目名稱:ChAsE,代碼行數:31,代碼來源:GuiUtils.java

示例7: drawHistogram

import processing.core.PGraphics; //導入方法依賴的package包/類
public static void drawHistogram(PGraphics p, double[] values, int iNumBins, float fLeft, float fTop, float fWidth, float fHeight, double dMaxBinValue, String xLabel, String yLabel, String[] xTicks)
{
	if (values == null || values.length == 0)
		return;
	
	double[] dBinVal = new double[iNumBins];
	double dMaxBinVal = dMaxBinValue;
	double dSum = 0;
	int ival = 0;
	for (int ibin = 0; ibin < iNumBins; ibin++)
	{
		while (ival < (ibin + 1) * values.length/iNumBins && ival < values.length)
		{
			dBinVal[ibin] += values[ival];
			ival++;
		}
		if (dMaxBinValue == -1)
		{
			dMaxBinVal = Math.max(dMaxBinVal, dBinVal[ibin]);
		}
		dSum += dBinVal[ibin];
	}

	float fBottom = fTop + fHeight;
	for (int ibin = 0; ibin < iNumBins; ibin++)
	{
		float h = -Math.min(fHeight, (float)(fHeight*dBinVal[ibin]/dMaxBinVal));
		p.rect(fLeft + ibin * fWidth / iNumBins, fBottom, fWidth / iNumBins, h);
	}
	
	// draw labels for the y axis
	NumberFormat nf = NumberFormat.getInstance();
	nf.setMaximumFractionDigits(1);
	
	//p.textAlign(PConstants.RIGHT, PConstants.TOP);
	//p.text(nf.format(100 * dMaxBinVal / dSum)+"%", fLeft - 5, fTop);
	
	// draw labels for the x axis
	if (xTicks != null)
	{
		p.textAlign(PConstants.CENTER, PConstants.TOP);
		for (int i = 0; i < xTicks.length; i++)
		{
			p.text(xTicks[i], fLeft + i * fWidth / (xTicks.length - 1), fBottom + 5);
		}
	}
	
	p.textAlign(PConstants.CENTER, PConstants.BOTTOM);
	p.text(xLabel, fLeft + fWidth / 2, fTop);

	p.textAlign(PConstants.CENTER, PConstants.TOP);
	p.pushMatrix();
	p.translate(fLeft + fWidth, fTop + fHeight / 2);
	p.rotate(-PConstants.PI/2);
	p.text(yLabel, 0, 0);
	p.popMatrix();

}
 
開發者ID:hyounesy,項目名稱:ChAsE,代碼行數:59,代碼來源:PUtils.java

示例8: apply

import processing.core.PGraphics; //導入方法依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  
  List<Object> params = ProcessingUtil.parseParams(stack, 1, 2);
      
  PGraphics pg = (PGraphics) params.get(0);

  String alignXstr = params.get(1).toString();
  int alignX = 0;
  
  if ("LEFT".equals(alignXstr)) {
    alignX = PGraphics.LEFT;
  } else if ("RIGHT".equals(alignXstr)) {
    alignX = PGraphics.RIGHT;
  } else if ("CENTER".equals(alignXstr)) {
    alignX = PGraphics.CENTER;
  } else {
    throw new WarpScriptException(getName() + " invalid alignment for X, should be 'LEFT', 'RIGHT' or 'CENTER'.");
  }
  
  if (2 == params.size()) {
    pg.textAlign(alignX);
  } else if (3 == params.size()) {
    String alignYstr = params.get(2).toString();
    int alignY = 0;
    
    if ("TOP".equals(alignYstr)) {
      alignY = PGraphics.TOP;
    } else if ("BOTTOM".equals(alignYstr)) {
      alignY = PGraphics.BOTTOM;
    } else if ("CENTER".equals(alignYstr)) {
      alignY = PGraphics.CENTER;
    } else if ("BASELINE".equals(alignYstr)) {
      alignY = PGraphics.BASELINE;
    } else {
      throw new WarpScriptException(getName() + " invalid alignment for Y, should be 'TOP', 'BOTTOM', 'CENTER' or 'BASELINE'.");
    }
    
    pg.textAlign(alignX, alignY);
  }

  stack.push(pg);
  
  return stack;
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:46,代碼來源:PtextAlign.java


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