本文整理汇总了Java中com.github.gwtd3.api.svg.Arc类的典型用法代码示例。如果您正苦于以下问题:Java Arc类的具体用法?Java Arc怎么用?Java Arc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Arc类属于com.github.gwtd3.api.svg包,在下文中一共展示了Arc类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveSliceIn
import com.github.gwtd3.api.svg.Arc; //导入依赖的package包/类
private void moveSliceIn(String categoryid, boolean animate) {
SliceDetails sd = this.categorySlices.get(categoryid);
if(animate) {
sd.categorySlice.transition().duration(outduration)
.attr("transform", "translate(0,0)");
radiusTransition(sd.optSliceArc,
sd.optFillSlice.transition().duration(outduration), optinnerradius);
sd.categorySlice.selectAll("text").transition().duration(outduration)
.attr("transform", "translate(0,0)");
}
else {
sd.categorySlice.attr("transform", "translate(0,0)");
sd.optFillSlice.datum(Arc.constantArc().outerRadius(optinnerradius));
sd.categorySlice.selectAll("text").attr("transform", "translate(0,0)");
}
}
示例2: moveSliceOut
import com.github.gwtd3.api.svg.Arc; //导入依赖的package包/类
private void moveSliceOut(String categoryid, boolean animate) {
SliceDetails sd = this.categorySlices.get(categoryid);
double dwidth = optradius - optinnerradius;
if(animate) {
sd.categorySlice.transition().duration(induration)
.attr("transform", "translate("+sd.dx*offset+","+sd.dy*offset+")");
radiusTransition(sd.optSliceArc,
sd.optFillSlice.transition().duration(induration), optradius);
sd.categorySlice.selectAll("text").transition().duration(induration)
.attr("transform", "translate("+sd.dx*dwidth+","+sd.dy*dwidth+")");
}
else {
sd.categorySlice.attr("transform", "translate("+sd.dx*offset+","+sd.dy*offset+")");
sd.optFillSlice.datum(Arc.constantArc().outerRadius(optradius));
sd.categorySlice.selectAll("text")
.attr("transform", "translate("+sd.dx*dwidth+","+sd.dy*dwidth+")");
}
}
示例3: SliceDetails
import com.github.gwtd3.api.svg.Arc; //导入依赖的package包/类
public SliceDetails(Selection categorySlice, Selection backgroundSlice,
Selection fillSlice, Selection optFillSlice,
Arc sliceArc, Arc optSliceArc,
double dx, double dy) {
this.categorySlice = categorySlice;
this.backgroundSlice = backgroundSlice;
this.fillSlice = fillSlice;
this.sliceArc = sliceArc;
this.optFillSlice = optFillSlice;
this.optSliceArc = optSliceArc;
this.dx = dx;
this.dy = dy;
}
示例4: radiusTransition
import com.github.gwtd3.api.svg.Arc; //导入依赖的package包/类
protected void radiusTransition(final Arc arc,
final Transition transition,
final double newRadius) {
transition.attrTween("d", new TweenFunction<String>() {
@Override
public Interpolator<String> apply(final Element context,
final Value datum, final int index,
final Value currentAttributeValue) {
try {
final Arc arcDatum = datum.as();
final double outerRadius = arcDatum.outerRadius();
return new CallableInterpolator<String>() {
private final Interpolator<Double> interpolator = Interpolators
.interpolateNumber(outerRadius, newRadius);
@Override
public String interpolate(final double t) {
double interpolated = interpolator.interpolate(t);
arcDatum.outerRadius(interpolated);
return arc.generate(arcDatum);
}
};
} catch (Exception e) {
throw new IllegalStateException("Error during transition",e);
}
}
});
}
示例5: angleTransition
import com.github.gwtd3.api.svg.Arc; //导入依赖的package包/类
protected void angleTransition(final Arc arc,
final Transition transition,
final double newAngle) {
transition.attrTween("d", new TweenFunction<String>() {
@Override
public Interpolator<String> apply(final Element context,
final Value datum, final int index,
final Value currentAttributeValue) {
try {
final Arc arcDatum = datum.as();
final double endAngle = arcDatum.endAngle();
return new CallableInterpolator<String>() {
private final Interpolator<Double> interpolator = Interpolators
.interpolateNumber(endAngle, newAngle);
@Override
public String interpolate(final double t) {
double interpolated = interpolator.interpolate(t);
arcDatum.endAngle(interpolated);
return arc.generate(arcDatum);
}
};
} catch (Exception e) {
throw new IllegalStateException("Error during transition",e);
}
}
});
}
示例6: doTransition
import com.github.gwtd3.api.svg.Arc; //导入依赖的package包/类
/**
* @param transition
* @param d
*/
protected void doTransition(final Transition transition,
final double newAngle) {
transition.attrTween("d", new TweenFunction<String>() {
@Override
public Interpolator<String> apply(final Element context,
final Value datum, final int index,
final Value currentAttributeValue) {
try {
final Arc arcDatum = datum.as();
final double endAngle = arcDatum.endAngle();
return new CallableInterpolator<String>() {
private final Interpolator<Double> interpolator = Interpolators
.interpolateNumber(endAngle, newAngle);
@Override
public String interpolate(final double t) {
double interpolated = interpolator.interpolate(t);
arcDatum.endAngle(interpolated);
return arc.generate(arcDatum);
}
};
} catch (Exception e) {
GWT.log("Error during transition", e);
throw new IllegalStateException("Error during transition",
e);
}
}
});
// transition.attrTween("d", "blah");
}
示例7: getArc
import com.github.gwtd3.api.svg.Arc; //导入依赖的package包/类
public Arc getArc() {
return Arc.constantArc().startAngle(startAngle).endAngle(endAngle);
}
示例8: fillCategories
import com.github.gwtd3.api.svg.Arc; //导入依赖的package包/类
@Override
public void fillCategories(boolean animate, boolean quickanimation) {
if(this.software == null)
return;
this.defs.remove();
this.defs = this.chart.append("defs");
double optstart = optinnerradius*100/optradius;
int i=0;
for(String catId : this.categorySlices.keySet()) {
SliceDetails sd = this.categorySlices.get(catId);
// Convert percentage to area-based percentage for a circular chart
double percentage = 100*Math.sqrt(this.getDonePercentage(catId)/100);
double optpercentage = 100*Math.sqrt(this.getDonePercentage(catId, true)/100);
//GWT.log(catId+" :"+percentage);
String sfx = this.getName() + "_" + i;
Selection grad = this.defs.append("radialGradient").attr("id", "innerGrad" + sfx)
.attr("gradientUnits", "userSpaceOnUse")
.attr("cx", 0).attr("cy", 0).attr("r", radius);
this.setGradient(grad, percentage);
Selection optgrad = this.defs.append("radialGradient").attr("id", "optGrad" + sfx)
.attr("gradientUnits", "userSpaceOnUse")
.attr("cx", 0).attr("cy", 0).attr("r", optradius);
this.setOptGradient(optgrad, optpercentage, optstart);
//if(animate) {
int duration = induration*2;
if(quickanimation)
duration = induration;
if(!animate)
duration = 0;
final Arc doneslicejson = Arc.constantArc().outerRadius(innerradius);
final Arc optdoneslicejson = Arc.constantArc().outerRadius(optinnerradius);
sd.fillSlice.datum(doneslicejson).style("fill", "url(#innerGrad" + sfx +")");
sd.optFillSlice.datum(optdoneslicejson).style("fill", "url(#optGrad" + sfx +")");
Transition transition = sd.fillSlice.transition().duration(duration);
radiusTransition(sd.sliceArc, transition, radius);
Transition opttransition = sd.optFillSlice.transition().duration(duration);
radiusTransition(sd.optSliceArc, opttransition, optradius);
/*}
else {
final Arc doneslicejson = Arc.constantArc().outerRadius(radius);
final Arc optdoneslicejson = Arc.constantArc().outerRadius(optradius);
sd.fillSlice.datum(doneslicejson).style("fill", "url(#innerGrad" + sfx +")");
sd.optFillSlice.datum(optdoneslicejson).style("fill", "url(#optGrad" + sfx +")");
}*/
i++;
}
}
示例9: start
import com.github.gwtd3.api.svg.Arc; //导入依赖的package包/类
@Override
public void start() {
int width = 960, height = 500;
final double TWO_PI = 2 * Math.PI; // http://tauday.com/tau-manifesto
// the arc function defines constants for inner and outer radius, and
// start angle
// but the end angle is deliberately kept undefined
arc = D3.svg().arc().innerRadius(180).outerRadius(240).startAngle(0);
// Create the SVG container, and apply a transform such that the origin
// is the center of the canvas. This way, we don't need to position
// arcs individually.
svg = D3.select(this)
.append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform",
"translate(" + (width / 2) + "," + (height / 2) + ")");
// construct a a stupid object containing the
// property "endAngle" as a constant.
Arc json = Arc.constantArc().endAngle(TWO_PI);
// Add the background arc, from 0 to 100%
// Here, the path d attribute is filled using the arc function,
// which will received in parameter the object passed to datum.
// This function will used the default accessors of the Arc objects,
// those accessors assuming that the data passed contains
// attributes named as the accessors.
svg.append("path")
// pass a data representing a constant endAngle arc
.datum(json).style("fill", "#ddd").attr("d", arc);
// set the angle to 12.7%
json.endAngle(.127 * TWO_PI);
// Add the foreground arc in orange, currently showing 12.7%.
final Selection foreground = svg.append("path").datum(json)
.style("fill", "orange").attr("d", arc);
centroidText = svg.append("text").text("centroid").datum(json)
.style("fill", "white").style("stroke", "black")
.style("font-size", "30px");
final int textWidth = getTextWidth(centroidText.node());
// Every so often, start a transition to a new random angle. Use //
// transition.call // (identical to selection.call) so that we can
// encapsulate the logic // for // tweening the arc in a separate
// function
// below.
timer = new Timer() {
@Override
public void run() {
Transition transition = foreground.transition().duration(750);
final double newAngle = Math.random() * TWO_PI;
doTransition(transition, newAngle);
centroidText.transition().duration(750)
.attr("transform", new DatumFunction<String>() {
@Override
public String apply(Element context, Value d,
int index) {
Arc newArc = Arc.copy(d.<Arc> as()).endAngle(
newAngle);
Array<Double> point = arc.centroid(newArc,
index);
return "translate("
+ (point.getNumber(0) - textWidth / 2)
+ "," + point.getNumber(1) + ")";
}
});
}
};
timer.scheduleRepeating(1500);
}