Esempio n. 1
0
void drvJAVA2::show_rectangle(const float llx, const float lly, const float urx, const float ury)
{
	if (numberOfElements > limitNumberOfElements)
		continue_page();
	outf << "    // Path # " << currentNr() << endl;
	outf << "    currentPage.add(new PSPathObject(new Color(";
	outf << currentR() << "f, " << currentG() << "f, " << currentB() << "f), ";
	outf << currentLineWidth() << "f";
	if ((currentLineJoin() != 0) || (currentShowType() != 0)) {
		outf << ", " << currentLineJoin();
		switch (currentShowType()) {
		case drvbase::stroke:
			outf << ", 0";
			break;
		case drvbase::fill:
			outf << ", 1";
			break;
		case drvbase::eofill:
			outf << ", 2";
			break;
		default:
			errf << "\t\tFatal: unexpected case for currentShowType() in drvjava2" << endl;	// cannot happen
			abort();
		}
	}
	if (currentLineType() != solid) {
		outf << "," << endl;
		show_dashPattern(outf, dashPattern());
	}
	outf << ", new Rectangle2D.Float(" << (llx +
										   x_offset) << "f, " <<
		(currentDeviceHeight - ury + y_offset) << "f";
	outf << ", " << (urx - llx) << "f, " << (ury - lly) << "f)));" << endl;
	numberOfElements++;
}
Esempio n. 2
0
void drvJAVA2::show_path()
{
	outf << "    // Path # " << currentNr() << endl;
	outf << "    currentPath = new PSPathObject(new Color(";
	outf << currentR() << "f, " << currentG() << "f, " << currentB() << "f), ";
	outf << currentLineWidth() << "f";
	if ((currentLineCap() != 0) || (currentLineJoin() != 0)
		|| (currentShowType() != 0) || (currentLineType() != solid)) {
		outf << ", " << currentLineCap() << ", " << currentLineJoin() <<
			", " << currentMiterLimit() << "f, ";
		switch (currentShowType()) {
		case drvbase::stroke:
			outf << "0";
			break;
		case drvbase::fill:
			outf << "1";
			break;
		case drvbase::eofill:
			outf << "2";
			break;
		default:
			errf << "\t\tFatal: unexpected case for currentShowType() in drvjava2" << endl;	// cannot happen
			abort();
		}
		if (currentLineType() != solid) {
			outf << "," << endl;
			show_dashPattern(outf, dashPattern());
		}
	}
	if (isPolygon()) {
		outf << ", true";
	}
	outf << ");" << endl;
	numberOfElements++;
	print_coords();
	outf << "    currentPage.add(currentPath);" << endl;
	numberOfElements++;
}
Esempio n. 3
0
// set libplot's cap style, join style, line style
void drvplot::set_line_style()
{
	// set cap style and join style
	(void)plotter->capmod(currentLineCap() == 0 ? "butt" :
					currentLineCap() == 1 ? "round" :
					currentLineCap() == 2 ? "projecting" : "butt");
	(void)plotter->joinmod(currentLineJoin() == 0 ? "miter" :
					 currentLineJoin() == 1 ? "round" : currentLineJoin() == 2 ? "bevel" : "miter");

	// set old-fashioned line style
	const char *linestyle;
	switch (currentLineType()) {
	case solid:
	default:
		linestyle = "solid";
		break;
	case dashed:
		linestyle = "longdashed";
		break;
	case dashdot:
		linestyle = "dotdashed";
		break;
	case dotted:
		linestyle = "dotted";
		break;
	case dashdotdot:
		linestyle = "dotdotdashed";
		break;
	}
	(void)plotter->linemod(linestyle);

	// set dashing pattern, which most types of Plotter understand
	DashPattern dash_pattern(dashPattern());
	double *numbers = new double[dash_pattern.nrOfEntries];
	for (int i = 0; i < dash_pattern.nrOfEntries; i++)
		numbers[i] = (double) dash_pattern.numbers[i];
	(void)plotter->flinedash(dash_pattern.nrOfEntries, numbers, (double) dash_pattern.offset);
	delete[]numbers;
}
Esempio n. 4
0
void drvFIG::show_path()
{
	float localLineWidth = currentLineWidth();
	localLineWidth *= 80.0f/72.0f; // xfig scales width differently - added in 3.50 - wogl
	// dont know whether this should be synchronized with -usecorrectfontsize option.



	/*
	3.50:
Originally, the resolution of Fig lines was 1/80 inch, and it was thought that the line width of "1" looked too thick, so it was reduced.
Therefore, the final width of lines in PostScript/EPS is:

Figwidth == 1: 7.5
Figwidth > 1: (Figwidth-1)*15

Regards,
Brian Smith

in reverse:

l < (15+7.5)/2 : f = 1
f = (l /15) + 1

	*/

	const float boundaryforOneCase = (((15.0f + 7.5f)/2.0f) / 15.0f);  // 0.75
	// if calculated linewidth is (without "+1 correction") > 0.75 
	// then apply correction by 1 
	// for the 0.75 case itself it means - map it to 1.75 and from there to 2
	// if it is < 0.75, then leave it so and create in fig a 1 ( (int) 0.75+0.5 )
	if (Verbose() ) {
		cerr << "localLineWidth " << localLineWidth  << " b " << boundaryforOneCase << endl;
	}
	if (localLineWidth > boundaryforOneCase) { 
		localLineWidth += 1.0f; // see above
	} else {
		// line width of 0 remain 0 - everything else is at least 1 
		if ((localLineWidth < 0.0) || ((localLineWidth > 0.0) && (localLineWidth <= 1.0))) {
			localLineWidth = 1.0;
		} 
	}

	unsigned int linestyle = 0;
	switch (currentLineType()) {
	case solid:
		linestyle = 0;
		break;
	case dashed:
		linestyle = 1;
		break;
	case dotted:
		linestyle = 2;
		break;
	case dashdot:
		linestyle = 3;
		break;
	case dashdotdot:
		linestyle = 4;
		break;
	}

	const unsigned int linecap = currentLineCap();
	const unsigned int linejoin = currentLineJoin();
	// Calculate BBox
	bbox_path();

	const unsigned int curvetos = nrOfCurvetos();
	if (curvetos == 0)			// polyline
	{
		buffer << "# polyline\n";
		buffer << "2 1 " << linestyle << " " << (int) (localLineWidth + 0.5f) << " ";
		const unsigned int color = registercolor(currentR(), currentG(), currentB());
		const int fill_or_nofill = (currentShowType() == drvbase::stroke) ? -1 : 20;
		if (objectId)
			objectId--;			// don't let it get < 0
		buffer << color << " " << color << " " << objectId << " 0 " <<
			fill_or_nofill << " " << "4.0" << 
			" " << linejoin << " " << linecap 
			//" 0 0"
			<< " 0 0 0 ";
		// 4.0 is the gap spec. we could also derive this from the input
		buffer << (int) (numberOfElementsInPath()) << "\n";
		print_polyline_coords();
	} else						// contains at least one curveto 
	{
		buffer << "# spline\n";
		// 3 2 means "open interpolated spline"
		buffer << "3 4 " << linestyle << " " << (int) (localLineWidth + 0.5f) << " ";
		const unsigned int color = registercolor(currentR(), currentG(), currentB());
		const int fill_or_nofill = (currentShowType() == drvbase::stroke) ? -1 : 20;
		if (objectId)
			objectId--;			// don't let it get < 0
		buffer << color << " " << color << " " << objectId << " 0 " <<
			fill_or_nofill << " " << "4.0" << //" 0"
			" " << linecap 
			<< " 0 0 ";
		// 4.0 is the gap spec. we could also derive this from the input

		// IJMP - change to quintic spline - 5 pnts per spline, not 3
		buffer << numberOfElementsInPath() + 5 * curvetos - curvetos << "\n";
		print_spline_coords1();
		print_spline_coords2();

	}
}