Java Code Examples for java.io.PrintWriter.append()

The following are Jave code examples for showing how to use append() of the java.io.PrintWriter class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: wangmarket   File: SiteController.java   View Source Code Vote up 6 votes
/**
 * 删除当前网站内的文件,删除OSS存储的数据
 * @param fileName 传入oss的key,如345.html、news/asd.jpg
 */
@RequestMapping("deleteOssData")
public void deleteOssData(Model model,HttpServletResponse response,
		@RequestParam(value = "fileName", required = true) String fileName){
	fileName = filter(fileName);
	AttachmentFile.deleteObject("site/"+getSiteId()+"/"+fileName);
	
	AliyunLog.addActionLog(getSiteId(), "删除当前网站内存储的文件:"+fileName);
	
	JSONObject json = new JSONObject();
	json.put("result", "1");
	response.setCharacterEncoding("UTF-8");  
    response.setContentType("application/json; charset=utf-8");  
    PrintWriter out = null;  
    try { 
        out = response.getWriter();  
        out.append(json.toString());
    } catch (IOException e) {  
        e.printStackTrace();  
    } finally {  
        if (out != null) {  
            out.close();  
        }  
    }  
}
 
Example 2
Project: wangmarket   File: SiteController.java   View Source Code Vote up 6 votes
/**
 * 通用电脑模式,更改底部的二维码,提交保存
 */
@RequestMapping(value = "popupQrImageUpdateSubmit")
public void popupQrImageUpdateSubmit(Model model,HttpServletRequest request,HttpServletResponse response,
		@RequestParam("qrImageFile") MultipartFile multipartFile) throws IOException{
	JSONObject json = new JSONObject();
	Site site = getSite();
	
	if(!(multipartFile.getContentType().equals("image/pjpeg") || multipartFile.getContentType().equals("image/jpeg") || multipartFile.getContentType().equals("image/png") || multipartFile.getContentType().equals("image/gif"))){
		json.put("result", "0");
		json.put("info", "请传入jpg、png、gif格式的二维码图");
	}else{
		//格式转换
		BufferedImage bufferedImage = ImageUtil.inputStreamToBufferedImage(multipartFile.getInputStream());
        BufferedImage tag = ImageUtil.formatConversion(bufferedImage);
        BufferedImage tag1 = ImageUtil.proportionZoom(tag, 400);
		
		//上传
        AttachmentFile.put("site/"+site.getId()+"/images/qr.jpg", ImageUtil.bufferedImageToInputStream(tag1, "jpg"));
		
		AliyunLog.addActionLog(getSiteId(), "通用电脑模式,更改底部的二维码,提交保存");
		
		json.put("result", "1");
	}
	
	response.setCharacterEncoding("UTF-8");  
    response.setContentType("application/json; charset=utf-8");  
    PrintWriter out = null;  
    try {  
        out = response.getWriter();  
        out.append(json.toString());
    } catch (IOException e) {  
        e.printStackTrace();  
    } finally {  
        if (out != null) {  
            out.close();  
        }  
    }  
}
 
Example 3
Project: RoughWorld   File: ViewObjectConcept.java   View Source Code Vote up 6 votes
public void out(WebRequest r,Object metadata,OutputStream s)
{
	PrintWriter pw = new PrintWriter( s );
	int ind = r.path.indexOf("/");
	String concept = r.path.substring(ind+1);
	//list the concepts
	pw.append("<h1>"+concept+"</h1>");

	pw.append("<h2>Instances</h2>");
	//the default taxonomy
	//view all the maps, objects etc. as lists
	File instsdir = new File("Concepts/"+concept+"/Instances");
	String[] insts = instsdir.list();
	for(int i=0;i<insts.length;i++)
	{
		String inst = insts[i];
		if(inst.startsWith(".")||inst.endsWith(".md"))
		{
			continue;
		}
		
		pw.append("<a href=\"/EditObjectInstance.html/"+concept+"/"+inst+"\">"+inst+"</a><br>");
	}
	pw.flush();
}
 
Example 4
Project: tomcat7   File: TestAbstractAjpProcessor.java   View Source Code Vote up 6 votes
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    resp.setBufferSize(bufferSize);

    resp.setContentType("text/plain");
    resp.setCharacterEncoding("UTF-8");
    resp.setContentLength(responseSize);

    PrintWriter pw = resp.getWriter();
    for (int i = 0; i < responseSize; i++) {
        pw.append('X');
    }
}
 
Example 5
Project: RoughWorld   File: ViewMapConcept.java   View Source Code Vote up 6 votes
public void out(WebRequest r,Object metadata,OutputStream s)
{
	PrintWriter pw = new PrintWriter( s );
	int ind = r.path.indexOf("/");
	String concept = r.path.substring(ind+1);
	//list the concepts
	pw.append("<h1>"+concept+"</h1>");

	pw.append("<h2>Instances</h2>");
	//the default taxonomy
	//view all the maps, objects etc. as lists
	File instsdir = new File("Concepts/"+concept+"/Instances");
	String[] insts = instsdir.list();
	for(int i=0;i<insts.length;i++)
	{
		String inst = insts[i];
		if(inst.startsWith(".")||inst.endsWith(".md"))
		{
			continue;
		}
		
		pw.append("<a href=\"/EditMapInstance.html/"+concept+"/"+inst+"\">"+inst+"</a><br>");
	}
	pw.flush();
}
 
Example 6
Project: springboot-security-wechat   File: MyAuthenticationSuccessHandler.java   View Source Code Vote up 5 votes
@Override
protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
    String targetUrl = this.determineTargetUrl(request, response);
    if(response.isCommitted()) {
        this.logger.debug("Response has already been committed. Unable to redirect to " + targetUrl);
    } else {
        ObjectMapper mapper = new ObjectMapper();
        response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
        response.setHeader("Access-Control-Allow-Credentials", "true");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Headers", "X-Request-With, JWCQ, Origin,Content-Type");
        response.setContentType("text/plain;charset='utf-8'");
        response.setCharacterEncoding("UTF-8");
        response.setStatus(200);

        // Our ajax request, redirect it to login web page
        Response response1 = new Response();
        response1.setSuccess(1);
        response1.setMessage("success");
        response1.setResult("登录成功");
        String responseStr = "";
        PrintWriter out = response.getWriter();
        try {
            responseStr = mapper.writeValueAsString(response1);
            out.append(responseStr);
        } catch (IOException ioe) {
            // FIXME: Add log here!
            out.append(ioe.toString());
        }
        out.close();
    }
}
 
Example 7
Project: n4js   File: NpmLogger.java   View Source Code Vote up 5 votes
/**
 * Dispatches given message with {@link Logger#error} and to the {@code STD_ERR} of used output stream. Additionally
 * will print stack trace of the provided throwable.
 */
public void logError(final String message, final Throwable t) {
	LOGGER.error(message, t);
	// Print writer is intentionally not released, its just a wrapper to log a message.
	final PrintWriter pw = new PrintWriter(osProvider.getOutputStream(STD_ERR, OutputRedirection.SUPPRESS));
	pw.append(getTimestamp() + message + lineSeparator());
	if (null != t) {
		pw.append(getTimestamp() + getStackTraceAsString(t) + lineSeparator());
	}
	pw.flush();
}
 
Example 8
Project: Equella   File: FileUtilsTest.java   View Source Code Vote up 5 votes
public void testRename() throws IOException, FileNotFoundException
{
	File testContent = new File(srcFolder, "tmp1");
	PrintWriter pw = new PrintWriter(testContent);
	pw.append("This is my file");
	pw.append("It has 3 lines");
	pw.append("So there");
	pw.close();

	destFolder = new File(tempFolder, "dest");
	Files.move(srcFolder, destFolder);
}
 
Example 9
Project: letv   File: AggregateException.java   View Source Code Vote up 5 votes
public void printStackTrace(PrintWriter err) {
    super.printStackTrace(err);
    int currentIndex = -1;
    for (Throwable throwable : this.innerThrowables) {
        err.append("\n");
        err.append("  Inner throwable #");
        currentIndex++;
        err.append(Integer.toString(currentIndex));
        err.append(": ");
        throwable.printStackTrace(err);
        err.append("\n");
    }
}
 
Example 10
Project: tqdev-metrics   File: InfluxDbReporter.java   View Source Code Vote up 5 votes
/**
 * Write.
 *
 * @param out
 *            the out
 */
public void write(OutputStream out) {
	PrintWriter w = new PrintWriter(out);
	String instanceStr = instanceName.replaceAll("[, =]", "\\$1");
	String time = String.valueOf((registry.getMillis() / 1000) * 1000000000);
	for (String type : registry.getTypes()) {
		String typeStr = type.replaceAll("[, ]", "\\$1");
		for (String key : registry.getKeys(type)) {
			String keyStr = key.replaceAll("[, =]", "\\$1");
			String parts[] = typeStr.split("\\.", 3);
			w.print(parts[0]);
			w.print(",host=");
			w.print(instanceStr);
			w.print(",instance=");
			if (parts.length > 1) {
				w.print(parts[1]);
			}
			w.print(",type=");
			if (parts.length > 2) {
				w.append(parts[2]);
			}
			w.print(",type_instance=");
			w.print(keyStr);
			w.print(" value=");
			w.print(registry.get(type, key));
			w.println("i " + time);
		}
	}
	w.close();
}
 
Example 11
Project: RoughWorld   File: EditPortalInstance.java   View Source Code Vote up 5 votes
public void out(WebRequest r,Object metadata,OutputStream s)
{
	PrintWriter pw = new PrintWriter( s );
	int ind = r.path.indexOf("/");
	String concept = r.path.substring(ind+1);
	ind = concept.indexOf("/");
	String instance = concept.substring(ind+1);
	concept = concept.substring(0,ind);

	String instancepath = "Concepts/"+concept+"/instances/"+instance;
	
	String datapath = instancepath+"/data.txt";
	
	ObjectLanguageInstance o = ObjectLanguageInstance.loadObject(fs, datapath);
	if(o==null)
	{
		o = new ObjectLanguageInstance();
		o.uniqueID = concept+"/"+instance;
		o.name = instance;
		o.type = "map";
		
		o.physicalRepresentation = new ObjectPhysicalInstance();
		
		ObjectLanguageInstance.saveObject(o, fs, datapath);
	}
	
	pw.append("<h1>"+concept+"/"+instance+"</h1>");

	printPortal(o,pw);
	
	EditUtils.printObjects(o, pw, fs);
	
	pw.flush();
}
 
Example 12
Project: tqdev-metrics   File: PrometheusReporter.java   View Source Code Vote up 5 votes
/**
 * Write.
 *
 * @param out
 *            the out
 */
public void write(OutputStream out) {
	PrintWriter w = new PrintWriter(out);
	String instanceStr = instanceName.replace("\\", "\\\\").replace("\n", "\\n").replace("\"", "\\\"");
	String time = String.valueOf((registry.getMillis() / 1000) * 1000);
	for (String type : registry.getTypes()) {
		String typeStr = type.replace("\\", "\\\\").replace("\n", "\\n").replace("\"", "\\\"");
		for (String key : registry.getKeys(type)) {
			String keyStr = key.replace("\\", "\\\\").replace("\n", "\\n").replace("\"", "\\\"");
			String parts[] = typeStr.split("\\.", 3);
			w.print(parts[0]);
			w.print("{host=\"");
			w.print(instanceStr);
			w.print("\",instance=\"");
			if (parts.length > 1) {
				w.print(parts[1]);
			}
			w.print("\",type=\"");
			if (parts.length > 2) {
				w.append(parts[2]);
			}
			w.print("\",type_instance=\"");
			w.print(keyStr);
			w.print("\"} ");
			w.print(registry.get(type, key));
			w.println(" " + time);
		}
	}
	w.close();
}
 
Example 13
Project: ipack   File: CodeResources.java   View Source Code Vote up 4 votes
private static void appendResource(final PrintWriter pw,
                                   final HashedResource hashedResource,
                                   final Boolean isFiles2) {
    //http://stackoverflow.com/a/32663908
    pw.append("\t\t<key>").append(xmlEscapeString(Normalizer.normalize(hashedResource.getName(), Normalizer.Form.NFD))).append("</key>\n");
    Pattern p = Pattern.compile("\\.nib$|\\/Info[^/]*\\.plist$");
    Matcher m = p.matcher(hashedResource.getName());
    Boolean shouldAddDict = isFiles2 || m.find();
    if(shouldAddDict) {
        pw.append("\t\t<dict>\n\t\t\t<key>hash</key>\n\t");
    }
    pw.append("\t\t<data>\n");
    if(shouldAddDict) {
        pw.append("\t");
    }
    pw.append("\t\t").append(hashedResource.getHash()).append('\n');
    if(shouldAddDict) {
        pw.append("\t");
    }
    pw.append("\t\t</data>\n");

    if(isFiles2) {
        pw.append("\t\t\t<key>hash2</key>\n\t\t\t<data>\n\t\t\t");
        pw.append(hashedResource.get256Hash()).append("\n\t\t\t</data>\n");
    }
    p = Pattern.compile("\\.png$");
    m = p.matcher(hashedResource.getName());
    Boolean isPng = m.find();
    p = Pattern.compile("Icon.*\\.png$|LaunchImage.*\\.png$");
    m = p.matcher(hashedResource.getName());
    Boolean isExcludedPng = m.find();
    p = Pattern.compile("^Assets.car$|^archived-expanded-entitlements.xcent$|^embedded.mobileprovision$|^entitlements.plist$");
    m = p.matcher(hashedResource.getName());
    Boolean otherExclusions = m.find();
    if(shouldAddDict) {
        if ((!isFiles2 && !isPng) || (isFiles2 && !otherExclusions && !isExcludedPng)) {
            pw.append("\t\t\t<key>optional</key>\n\t\t\t<true/>\n");
        }
    }
    if(shouldAddDict) {
        pw.append("\t\t</dict>\n");
    }
}
 
Example 14
Project: RoughWorld   File: EditObjectInstance.java   View Source Code Vote up 4 votes
public void out(WebRequest r,Object metadata,OutputStream s)
	{
		PrintWriter pw = new PrintWriter( s );
		int ind = r.path.indexOf("/");
		String concept = r.path.substring(ind+1);
		ind = concept.indexOf("/");
		String instance = concept.substring(ind+1);
		concept = concept.substring(0,ind);

		String instancepath = "Concepts/"+concept+"/instances/"+instance;
		
		String datapath = instancepath+"/data.txt";
		
		ObjectLanguageInstance o = ObjectLanguageInstance.loadObject(fs, datapath);
		if(o==null)
		{
			o = new ObjectLanguageInstance();
			o.uniqueID = concept+"/"+instance;
			o.name = instance;
			o.type = "map";
			
			o.physicalRepresentation = new ObjectPhysicalInstance();
			
			ObjectLanguageInstance.saveObject(o, fs, datapath);
		}
		
//		if(o.physicalRepresentation.shape instanceof ModifiedCopyShape)
//		{
//			ModifiedCopyShape mcs = (ModifiedCopyShape)o.physicalRepresentation.shape;
//			mcs.buildParametersAndSides();
//			ObjectLanguageInstance.saveObject(o, fs, datapath);
//		}

		pw.append("<h1>"+concept+"/"+instance+"</h1>");

		printObject(o,pw);
		
		EditUtils.printObjects(o, pw, fs);
		
		pw.flush();
	}
 
Example 15
Project: RoughWorld   File: StateToSVG.java   View Source Code Vote up 4 votes
public static void containsToSVG(PrintWriter pw,FileStoreInterface fs,ObjectLanguageInstance o,
		int[] origin,int inset,double scale,boolean printtext,
		GeneralMatrixDouble parentRelativeToWorldtran,
		int remainingDepth,
		boolean as3D)
{
	double[] dimensions = new double[3];
	double[] ctrans = o.physicalRepresentation.contains_metric_transform;
	for(int i=0;i<o.contains.length;i++)
	{
		String cid = o.contains[i];
		
		String cpath = ObjectLanguageInstance.uniqueIdToPath(cid);
		ObjectLanguageInstance c = ObjectLanguageInstance.loadObject(fs, cpath+"/data.txt");
		
		ParametricShape cshape = c.physicalRepresentation.shape;
		if(cshape!=null)
		{
			//compose the transforms
			int coff = i*12;
			GeneralMatrixDouble containedRelativeToParenttran = new GeneralMatrixDouble(4,4);
			containedRelativeToParenttran.setIdentity();
			for(int ti=0;ti<3;ti++)
				containedRelativeToParenttran.value[ti] = ctrans[coff+ti];
			for(int ti=0;ti<3;ti++)
				containedRelativeToParenttran.value[4+ti] = ctrans[coff+3+ti];
			for(int ti=0;ti<3;ti++)
				containedRelativeToParenttran.value[8+ti] = ctrans[coff+6+ti];
			containedRelativeToParenttran.set3DTransformPosition(ctrans[coff+9], ctrans[coff+10], ctrans[coff+11]);

			GeneralMatrixDouble containedRelativeToWorld = new GeneralMatrixDouble(4,4);
			
			//GeneralMatrixDouble.mult(parentRelativeToWorldtran, containedRelativeToParenttran, containedRelativeToWorld);
			
			GeneralMatrixDouble.mult(containedRelativeToParenttran, parentRelativeToWorldtran, containedRelativeToWorld);
			
			double x = containedRelativeToWorld.value[4*3+0];
			double y = containedRelativeToWorld.value[4*3+1];
			double z = containedRelativeToWorld.value[4*3+2];
			
			//addShape(cshape,origin[0]+x*scale,origin[1]+y*scale, scale,false, pw);
			addWireframeShape(cshape,containedRelativeToWorld, origin, scale, false, as3D, pw);
			
			if((remainingDepth>0)&&(c.contains.length>0))
			{
				containsToSVG(pw, fs, c, origin, inset, scale, false, containedRelativeToWorld, remainingDepth-1, as3D);
			}
			
			if(printtext)
			{
				cshape.getCuboidDimensions(dimensions);
				
				if(dimensions[0]<0.5)
				{
					pw.append("<g writing-mode=\"tb-rl\" font-size=\"14px\" font-family=\"Verdana\"\">");
				    //<text y="50px" text-anchor="middle">Direction</text>
					pw.append("<text fill=\"#000000\" x=\""+(7+inset+(x)*scale)+"\" y=\""+(inset+1+(y)*scale)+"\">"+c.name+"</text>");
					pw.append("</g>");
				}
				else
				{
					pw.append("<g writing-mode=\"lr-tb\" font-size=\"14px\" font-family=\"Verdana\"\">");
					pw.append("<text fill=\"#000000\" x=\""+(inset+x*scale)+"\" y=\""+(inset-1+(y+dimensions[1])*scale)+"\">"+c.name+"</text>");
					pw.append("</g>");
				}
			}	
		}
		
	}

}
 
Example 16
Project: RoughWorld   File: RoughWorldIndex.java   View Source Code Vote up 4 votes
public void out(WebRequest r,Object metadata,OutputStream s)
{
	PrintWriter pw = new PrintWriter( s );
	pw.append("Hello World");
	pw.flush();
}
 
Example 17
Project: RoughWorld   File: StateToSVG.java   View Source Code Vote up 4 votes
public static void startSVG3D(ParametricShape shape,int inset,int ceiling_height,double scale,int[] origins,PrintWriter pw)
	{
		double[] dims = new double[3];
		shape.getCuboidDimensions(dims);
//		if(shape instanceof RectangularPortal)
//		{
//			RectangularPortal rbuild = (RectangularPortal)shape;
//			double w = rbuild.parameters[0];
//			double h = rbuild.parameters[1];
//			double d = rbuild.parameters[2];
			double w = dims[0];
			double h = dims[1];
			double d = dims[2];
			int wi = (int)(w*scale);
			int hi = (int)(h*scale);
			int di = (int)(d*scale);

			int width = (wi+hi+inset*3);
			int height = (hi+ceiling_height+inset);
			
			origins[0] = inset;
			origins[1] = inset;
			
			origins[2] = inset;
			origins[3] = inset+(hi+inset)+ceiling_height;

			origins[4] = inset+(wi+inset*3);
			origins[5] = inset+(hi+inset)+ceiling_height;

			
			pw.append("<svg width=\""+(width+inset*2)+"\" height=\""+(height+inset*2)+"\">");
			
//		}
//		else
//		if(shape instanceof Cuboid)
//		{
//			Cuboid rbuild = (Cuboid)shape;
//			double w = rbuild.parameters[0];
//			double h = rbuild.parameters[1];
//			double d = rbuild.parameters[2];
//			int wi = (int)(w*scale);
//			int hi = (int)(h*scale);
//			int di = (int)(d*scale);
//
//			int width = (wi+hi+inset*3);
//			int height = (hi+ceiling_height+inset);
//			
//			origins[0] = inset;
//			origins[1] = inset;
//			
//			origins[2] = inset;
//			origins[3] = inset+(hi+inset)+ceiling_height;
//
//			origins[4] = inset+(wi+inset*3);
//			origins[5] = inset+(hi+inset)+ceiling_height;
//
//			
//			pw.append("<svg width=\""+(width+inset*2)+"\" height=\""+(height+inset*2)+"\">");
//			
//		}
	}
 
Example 18
Project: wangmarket   File: SiteController.java   View Source Code Vote up 4 votes
/**
 * 电脑模式,更改关于我们的图片 ,提交
 */
@RequestMapping("popupAboutUsImageUpdateSubmit")
public void popupAboutUsImageUpdateSubmit(HttpServletRequest request,Model model,HttpServletResponse response,
		@RequestParam("titlePicFile") MultipartFile multipartFile){
	JSONObject json = new JSONObject();
	Site site = getSite();
	
	News news = (News) sqlService.findAloneBySqlQuery("SELECT news.* FROM news WHERE news.cid = "+getSite().getAboutUsCid(), News.class);
	if(news == null){
		//关于我们栏目未发现
		return;
	}
	
	UploadFileVO uploadFileVO = AttachmentFile.uploadImage("site/"+site.getId()+"/news/", request, "titlePicFile", G.NEWS_TITLEPIC_MAXWIDTH);
	String oldTitlePic = "";	//旧的栏目导航图名字
	if(uploadFileVO.getResult() == UploadFileVO.SUCCESS){
		oldTitlePic = (news.getTitlepic()==null||news.getTitlepic().length()==0)? "":news.getTitlepic();
		
		news.setTitlepic(uploadFileVO.getFileName());
		sqlService.save(news);
		
		//如果有旧图,删除掉旧的图片
		if(oldTitlePic.length() > 0 && oldTitlePic.indexOf("http://") == -1){
			AttachmentFile.deleteObject("site/"+site.getId()+"/news/"+oldTitlePic);
		}
		
		//更新首页
		SiteColumn siteColumn = (SiteColumn) sqlService.findById(SiteColumn.class, news.getCid());
		NewsData newsData = (NewsData) sqlService.findById(NewsData.class, news.getId());
		IndexAboutUs.refreshIndexData(site, siteColumn, news, newsData == null ? "":newsData.getText());
		
		AliyunLog.addActionLog(getSiteId(), "通用电脑模式,关于我们图片更改成功");
		
		json.put("result", "1");
	}else{
		json.put("result", "0");
		json.put("info", uploadFileVO.getInfo());
	}
	
	
	response.setCharacterEncoding("UTF-8");  
    response.setContentType("application/json; charset=utf-8");  
    PrintWriter out = null;  
    try {  
        out = response.getWriter();  
        out.append(json.toString());
    } catch (IOException e) {  
        e.printStackTrace();  
    } finally {  
        if (out != null) {  
            out.close();  
        }  
    }  
}
 
Example 19
Project: RoughWorld   File: StateToSVG.java   View Source Code Vote up 4 votes
public static void containsToSVG3D(PrintWriter pw,FileStoreInterface fs,ObjectLanguageInstance o,
		int[] origins,int inset,double scale,boolean printtext,
		GeneralMatrixDouble parentRelativeToWorldtran,
		int remainingDepth)
{
	double[] dimensions = new double[3];
	double[] ctrans = o.physicalRepresentation.contains_metric_transform;
	for(int i=0;i<o.contains.length;i++)
	{
		String cid = o.contains[i];
		
		String cpath = ObjectLanguageInstance.uniqueIdToPath(cid);
		ObjectLanguageInstance c = ObjectLanguageInstance.loadObject(fs, cpath+"/data.txt");
		
		ParametricShape cshape = c.physicalRepresentation.shape;
		if(cshape!=null)
		{
			//compose the transforms
			int coff = i*12;
			GeneralMatrixDouble containedRelativeToParenttran = new GeneralMatrixDouble(4,4);
			containedRelativeToParenttran.setIdentity();
			for(int ti=0;ti<3;ti++)
				containedRelativeToParenttran.value[ti] = ctrans[coff+ti];
			for(int ti=0;ti<3;ti++)
				containedRelativeToParenttran.value[4+ti] = ctrans[coff+3+ti];
			for(int ti=0;ti<3;ti++)
				containedRelativeToParenttran.value[8+ti] = ctrans[coff+6+ti];
			containedRelativeToParenttran.set3DTransformPosition(ctrans[coff+9], ctrans[coff+10], ctrans[coff+11]);

			GeneralMatrixDouble containedRelativeToWorld = new GeneralMatrixDouble(4,4);
			
			GeneralMatrixDouble.mult(parentRelativeToWorldtran, containedRelativeToParenttran, containedRelativeToWorld);
			
			double x = containedRelativeToWorld.value[4*3+0];
			double y = containedRelativeToWorld.value[4*3+1];
			double z = containedRelativeToWorld.value[4*3+2];
			
			addShape3D(cshape,x*scale,y*scale,-z*scale, scale, origins, pw);
			
			if((remainingDepth>0)&&(c.contains.length>0))
			{
				containsToSVG3D(pw, fs, c, origins, inset, scale, false, containedRelativeToWorld, remainingDepth-1);
			}
			
			if(printtext)
			{
				cshape.getCuboidDimensions(dimensions);
				
				if(dimensions[0]<0.5)
				{
					pw.append("<g writing-mode=\"tb-rl\" font-size=\"14px\" font-family=\"Verdana\"\">");
				    //<text y="50px" text-anchor="middle">Direction</text>
					pw.append("<text fill=\"#000000\" x=\""+(7+inset+(x)*scale)+"\" y=\""+(inset+1+(y)*scale)+"\">"+c.name+"</text>");
					pw.append("</g>");
				}
				else
				{
					pw.append("<g writing-mode=\"lr-tb\" font-size=\"14px\" font-family=\"Verdana\"\">");
					pw.append("<text fill=\"#000000\" x=\""+(inset+x*scale)+"\" y=\""+(inset-1+(y+dimensions[1])*scale)+"\">"+c.name+"</text>");
					pw.append("</g>");
				}
			}	
		}
		
	}

}
 
Example 20
Project: DeBrug   File: VisualisatieToestandenEnOvergangen.java   View Source Code Vote up 4 votes
private void WriteRelatie(PrintWriter gvWriter, String from, String to) {
  gvWriter.append("\"" + from + "\"" + "->" + "\"" + to + "\"" + ";" + "\n");
}