/**
* Modify the GeometricLayer so the layer coordinate system matches the image coordinate system ("pixel" projection).
*/
public static GeometryImage createImageProjected(GeometryImage layer, AffineTransform geoTransform) {
for(Geometry geom:layer.geoms){
for(Coordinate pos:geom.getCoordinates()){
Point2D.Double temp=new Point2D.Double();
try {
geoTransform.inverseTransform(new Point2D.Double(pos.x, pos.y),temp);
} catch (NoninvertibleTransformException e) {
e.printStackTrace();
}
pos.x=temp.x;
pos.y=temp.y;
}
}
return layer;
}
java类java.awt.geom.NoninvertibleTransformException的实例源码
GeometryImage.java 文件源码
项目:sumo
阅读 28
收藏 0
点赞 0
评论 0
StandardGlyphVector.java 文件源码
项目:OpenJSharp
阅读 25
收藏 0
点赞 0
评论 0
/**
* !!! not used currently, but might be by getPixelbounds?
*/
public void pixellate(FontRenderContext renderFRC, Point2D loc, Point pxResult) {
if (renderFRC == null) {
renderFRC = frc;
}
// it is a total pain that you have to copy the transform.
AffineTransform at = renderFRC.getTransform();
at.transform(loc, loc);
pxResult.x = (int)loc.getX(); // but must not behave oddly around zero
pxResult.y = (int)loc.getY();
loc.setLocation(pxResult.x, pxResult.y);
try {
at.inverseTransform(loc, loc);
}
catch (NoninvertibleTransformException e) {
throw new IllegalArgumentException("must be able to invert frc transform");
}
}
StandardGlyphVector.java 文件源码
项目:OpenJSharp
阅读 22
收藏 0
点赞 0
评论 0
/**
* Change the dtx for the strike refs we use. Keeps a reference to the at. At
* must not contain translation.
* Called by setRenderTransform, setDTX, initFontData.
*/
private final void resetDTX(AffineTransform at) {
fsref = null;
dtx = at;
invdtx = null;
if (!dtx.isIdentity()) {
try {
invdtx = dtx.createInverse();
}
catch (NoninvertibleTransformException e) {
// we needn't care for rendering
}
}
if (gti != null) {
gti.strikesRef = null;
}
}
AttributeValues.java 文件源码
项目:OpenJSharp
阅读 23
收藏 0
点赞 0
评论 0
private static AffineTransform extractRotation(Point2D.Double pt,
AffineTransform tx, boolean andTranslation) {
tx.deltaTransform(pt, pt);
AffineTransform rtx = AffineTransform.getRotateInstance(pt.x, pt.y);
try {
AffineTransform rtxi = rtx.createInverse();
double dx = tx.getTranslateX();
double dy = tx.getTranslateY();
tx.preConcatenate(rtxi);
if (andTranslation) {
if (dx != 0 || dy != 0) {
tx.setTransform(tx.getScaleX(), tx.getShearY(),
tx.getShearX(), tx.getScaleY(), 0, 0);
rtx.setTransform(rtx.getScaleX(), rtx.getShearY(),
rtx.getShearX(), rtx.getScaleY(), dx, dy);
}
}
}
catch (NoninvertibleTransformException e) {
return null;
}
return rtx;
}
StandardGlyphVector.java 文件源码
项目:jdk8u-jdk
阅读 22
收藏 0
点赞 0
评论 0
/**
* !!! not used currently, but might be by getPixelbounds?
*/
public void pixellate(FontRenderContext renderFRC, Point2D loc, Point pxResult) {
if (renderFRC == null) {
renderFRC = frc;
}
// it is a total pain that you have to copy the transform.
AffineTransform at = renderFRC.getTransform();
at.transform(loc, loc);
pxResult.x = (int)loc.getX(); // but must not behave oddly around zero
pxResult.y = (int)loc.getY();
loc.setLocation(pxResult.x, pxResult.y);
try {
at.inverseTransform(loc, loc);
}
catch (NoninvertibleTransformException e) {
throw new IllegalArgumentException("must be able to invert frc transform");
}
}
StandardGlyphVector.java 文件源码
项目:jdk8u-jdk
阅读 23
收藏 0
点赞 0
评论 0
/**
* Change the dtx for the strike refs we use. Keeps a reference to the at. At
* must not contain translation.
* Called by setRenderTransform, setDTX, initFontData.
*/
private final void resetDTX(AffineTransform at) {
fsref = null;
dtx = at;
invdtx = null;
if (!dtx.isIdentity()) {
try {
invdtx = dtx.createInverse();
}
catch (NoninvertibleTransformException e) {
// we needn't care for rendering
}
}
if (gti != null) {
gti.strikesRef = null;
}
}
AttributeValues.java 文件源码
项目:jdk8u-jdk
阅读 30
收藏 0
点赞 0
评论 0
private static AffineTransform extractRotation(Point2D.Double pt,
AffineTransform tx, boolean andTranslation) {
tx.deltaTransform(pt, pt);
AffineTransform rtx = AffineTransform.getRotateInstance(pt.x, pt.y);
try {
AffineTransform rtxi = rtx.createInverse();
double dx = tx.getTranslateX();
double dy = tx.getTranslateY();
tx.preConcatenate(rtxi);
if (andTranslation) {
if (dx != 0 || dy != 0) {
tx.setTransform(tx.getScaleX(), tx.getShearY(),
tx.getShearX(), tx.getScaleY(), 0, 0);
rtx.setTransform(rtx.getScaleX(), rtx.getShearY(),
rtx.getShearX(), rtx.getScaleY(), dx, dy);
}
}
}
catch (NoninvertibleTransformException e) {
return null;
}
return rtx;
}
StandardGlyphVector.java 文件源码
项目:openjdk-jdk10
阅读 27
收藏 0
点赞 0
评论 0
/**
* !!! not used currently, but might be by getPixelbounds?
*/
public void pixellate(FontRenderContext renderFRC, Point2D loc, Point pxResult) {
if (renderFRC == null) {
renderFRC = frc;
}
// it is a total pain that you have to copy the transform.
AffineTransform at = renderFRC.getTransform();
at.transform(loc, loc);
pxResult.x = (int)loc.getX(); // but must not behave oddly around zero
pxResult.y = (int)loc.getY();
loc.setLocation(pxResult.x, pxResult.y);
try {
at.inverseTransform(loc, loc);
}
catch (NoninvertibleTransformException e) {
throw new IllegalArgumentException("must be able to invert frc transform");
}
}
StandardGlyphVector.java 文件源码
项目:openjdk-jdk10
阅读 29
收藏 0
点赞 0
评论 0
/**
* Change the dtx for the strike refs we use. Keeps a reference to the at. At
* must not contain translation.
* Called by setRenderTransform, setDTX, initFontData.
*/
private final void resetDTX(AffineTransform at) {
fsref = null;
dtx = at;
invdtx = null;
if (!dtx.isIdentity()) {
try {
invdtx = dtx.createInverse();
}
catch (NoninvertibleTransformException e) {
// we needn't care for rendering
}
}
if (gti != null) {
gti.strikesRef = null;
}
}
AttributeValues.java 文件源码
项目:openjdk-jdk10
阅读 21
收藏 0
点赞 0
评论 0
private static AffineTransform extractRotation(Point2D.Double pt,
AffineTransform tx, boolean andTranslation) {
tx.deltaTransform(pt, pt);
AffineTransform rtx = AffineTransform.getRotateInstance(pt.x, pt.y);
try {
AffineTransform rtxi = rtx.createInverse();
double dx = tx.getTranslateX();
double dy = tx.getTranslateY();
tx.preConcatenate(rtxi);
if (andTranslation) {
if (dx != 0 || dy != 0) {
tx.setTransform(tx.getScaleX(), tx.getShearY(),
tx.getShearX(), tx.getScaleY(), 0, 0);
rtx.setTransform(rtx.getScaleX(), rtx.getShearY(),
rtx.getShearX(), rtx.getScaleY(), dx, dy);
}
}
}
catch (NoninvertibleTransformException e) {
return null;
}
return rtx;
}
StandardGlyphVector.java 文件源码
项目:openjdk9
阅读 22
收藏 0
点赞 0
评论 0
/**
* !!! not used currently, but might be by getPixelbounds?
*/
public void pixellate(FontRenderContext renderFRC, Point2D loc, Point pxResult) {
if (renderFRC == null) {
renderFRC = frc;
}
// it is a total pain that you have to copy the transform.
AffineTransform at = renderFRC.getTransform();
at.transform(loc, loc);
pxResult.x = (int)loc.getX(); // but must not behave oddly around zero
pxResult.y = (int)loc.getY();
loc.setLocation(pxResult.x, pxResult.y);
try {
at.inverseTransform(loc, loc);
}
catch (NoninvertibleTransformException e) {
throw new IllegalArgumentException("must be able to invert frc transform");
}
}
StandardGlyphVector.java 文件源码
项目:openjdk9
阅读 23
收藏 0
点赞 0
评论 0
/**
* Change the dtx for the strike refs we use. Keeps a reference to the at. At
* must not contain translation.
* Called by setRenderTransform, setDTX, initFontData.
*/
private final void resetDTX(AffineTransform at) {
fsref = null;
dtx = at;
invdtx = null;
if (!dtx.isIdentity()) {
try {
invdtx = dtx.createInverse();
}
catch (NoninvertibleTransformException e) {
// we needn't care for rendering
}
}
if (gti != null) {
gti.strikesRef = null;
}
}
AttributeValues.java 文件源码
项目:openjdk9
阅读 23
收藏 0
点赞 0
评论 0
private static AffineTransform extractRotation(Point2D.Double pt,
AffineTransform tx, boolean andTranslation) {
tx.deltaTransform(pt, pt);
AffineTransform rtx = AffineTransform.getRotateInstance(pt.x, pt.y);
try {
AffineTransform rtxi = rtx.createInverse();
double dx = tx.getTranslateX();
double dy = tx.getTranslateY();
tx.preConcatenate(rtxi);
if (andTranslation) {
if (dx != 0 || dy != 0) {
tx.setTransform(tx.getScaleX(), tx.getShearY(),
tx.getShearX(), tx.getScaleY(), 0, 0);
rtx.setTransform(rtx.getScaleX(), rtx.getShearY(),
rtx.getShearX(), rtx.getScaleY(), dx, dy);
}
}
}
catch (NoninvertibleTransformException e) {
return null;
}
return rtx;
}
Coord.java 文件源码
项目:geokuk
阅读 23
收藏 0
点赞 0
评论 0
private void computeAffineTransforms() {
if (natoceni == 0) {
tam = null;
zpet = null;
return;
}
final AffineTransform tra = new AffineTransform();
final double widthPul = (double) dim.width / 2;
final double heightPul = (double) dim.height / 2;
tra.translate(widthPul, heightPul);
tra.rotate(natoceni);
tra.translate(-widthPul, -heightPul);
tam = tra;
try {
zpet = tam.createInverse();
} catch (final NoninvertibleTransformException e) {
throw new RuntimeException(e);
}
}
RadiometricMeasurementCanvas.java 文件源码
项目:PhET
阅读 22
收藏 0
点赞 0
评论 0
@Override
protected void updateLayout() {
super.updateLayout();
// Set the bounding node to match exactly the size of the viewport.
AffineTransform transform = getWorldTransformStrategy().getTransform();
AffineTransform inverseTransform;
try {
inverseTransform = transform.createInverse();
}
catch ( NoninvertibleTransformException e ) {
System.err.println( getClass().getName() + " - Error: Unable to invert transform." );
e.printStackTrace();
inverseTransform = new AffineTransform(); // Unity transform by default.
}
Shape tranformedBounds = inverseTransform.createTransformedShape( getBounds() );
_probeDragBounds.setPathTo( tranformedBounds );
}
AmplitudeSlider.java 文件源码
项目:PhET
阅读 21
收藏 0
点赞 0
评论 0
private void setAmplitude( Point mousePoint ) {
double localY = 0;
try {
AffineTransform transform = getNetTransform();
transform.inverseTransform( mousePoint, _somePoint /* output */ );
localY = _somePoint.getY();
}
catch ( NoninvertibleTransformException e ) {
e.printStackTrace();
}
localY = -localY; // +Y is up
double amplitude = MAX_AMPLITUDE * ( localY / ( _maxSize.height / 2.0 ) );
amplitude = MathUtil.clamp( -MAX_AMPLITUDE, amplitude, +MAX_AMPLITUDE );
_harmonic.setAmplitude( amplitude );
fireChangeEvent();
}
Group.java 文件源码
项目:cachebox3.0
阅读 26
收藏 0
点赞 0
评论 0
@Override
void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException
{
Point2D xPoint = new Point2D.Double(point.getX(), point.getY());
if (xform != null)
{
try
{
xform.inverseTransform(point, xPoint);
} catch (NoninvertibleTransformException ex)
{
throw new SVGException(ex);
}
}
for (SVGElement ele : children) {
if (ele instanceof RenderableElement)
{
RenderableElement rendEle = (RenderableElement) ele;
rendEle.pick(xPoint, boundingBox, retVec);
}
}
}
RenderGL11Util.java 文件源码
项目:geoxygene
阅读 25
收藏 0
点赞 0
评论 0
/**
* @param geometry
* geometry to fill
* @param viewport
* viewport
* @param graphics
* graphics to draw into
*/
@SuppressWarnings("unchecked")
public static void fill(final IGeometry geometry, final Viewport viewport, final double opacity) {
if (geometry.isPolygon()) {
try {
Shape shape = viewport.toShape(geometry);
if (shape != null) {
glFillNearlySimpleShape(shape);
}
} catch (NoninvertibleTransformException e) {
e.printStackTrace();
}
} else {
if (geometry.isMultiSurface()) {
GM_Aggregate<IGeometry> aggregate = (GM_Aggregate<IGeometry>) geometry;
for (IGeometry element : aggregate) {
RenderGL11Util.fill(element, viewport, opacity);
}
}
}
}
CairoGraphics2D.java 文件源码
项目:javify
阅读 19
收藏 0
点赞 0
评论 0
public void transform(AffineTransform tx)
{
if (transform == null)
transform = new AffineTransform(tx);
else
transform.concatenate(tx);
if (clip != null)
{
try
{
AffineTransform clipTransform = tx.createInverse();
updateClip(clipTransform);
}
catch (NoninvertibleTransformException ex)
{
// TODO: How can we deal properly with this?
ex.printStackTrace();
}
}
setTransformImpl(transform);
}
AttributeValues.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 29
收藏 0
点赞 0
评论 0
private static AffineTransform extractRotation(Point2D.Double pt,
AffineTransform tx, boolean andTranslation) {
tx.deltaTransform(pt, pt);
AffineTransform rtx = AffineTransform.getRotateInstance(pt.x, pt.y);
try {
AffineTransform rtxi = rtx.createInverse();
double dx = tx.getTranslateX();
double dy = tx.getTranslateY();
tx.preConcatenate(rtxi);
if (andTranslation) {
if (dx != 0 || dy != 0) {
tx.setTransform(tx.getScaleX(), tx.getShearY(),
tx.getShearX(), tx.getScaleY(), 0, 0);
rtx.setTransform(rtx.getScaleX(), rtx.getShearY(),
rtx.getShearX(), rtx.getScaleY(), dx, dy);
}
}
}
catch (NoninvertibleTransformException e) {
return null;
}
return rtx;
}
QuPathViewer.java 文件源码
项目:qupath
阅读 22
收藏 0
点赞 0
评论 0
protected void updateAffineTransform() {
if (!hasServer())
return;
transform.setToIdentity();
transform.translate(getWidth()*.5, getHeight()*.5);
transform.scale(1.0/downsampleFactor, 1.0/downsampleFactor);
transform.translate(-xCenter, -yCenter);
if (rotation != 0)
transform.rotate(rotation, xCenter, yCenter);
transformInverse.setTransform(transform);
try {
transformInverse.invert();
} catch (NoninvertibleTransformException e) {
e.printStackTrace();
}
}
SLDDemoApplication.java 文件源码
项目:geoxygene
阅读 22
收藏 0
点赞 0
评论 0
public void displayCercles() {
// ProjectFrame projectFrame =
// application.getMainFrame().newProjectFrame();
this.exampleGraphicFill_Fill_Polygon();
this.exampleGraphicFill_Stroke_Polygon();
this.exampleGraphicStroke_Stroke_Polygon();
this.exampleShadow();
this.exampleGraphicStroke_Line();
this.exampleGraphicFill_Line();
this.exampleTexture();
FileWriter fichier;
try {
fichier = new FileWriter("./src/main/resources/sld/GraphicMark.xml");
this.projectFrame.getSld().marshall(fichier);
} catch (IOException e1) {
e1.printStackTrace();
}
try {
this.projectFrame.getLayerViewPanel().getViewport().zoomToFullExtent();
} catch (NoninvertibleTransformException e) {
e.printStackTrace();
}
}
AbstractGraphicsNode.java 文件源码
项目:Push2Display
阅读 20
收藏 0
点赞 0
评论 0
/**
* Sets the transform of this node.
*
* @param newTransform the new transform of this node
*/
public void setTransform(AffineTransform newTransform) {
fireGraphicsNodeChangeStarted();
this.transform = newTransform;
if(transform.getDeterminant() != 0){
try{
inverseTransform = transform.createInverse();
}catch(NoninvertibleTransformException e){
// Should never happen.
throw new Error( e.getMessage() );
}
} else {
// The transform is not invertible. Use the same
// transform.
inverseTransform = transform;
}
if (parent != null)
parent.invalidateGeometryCache();
fireGraphicsNodeChangeCompleted();
}
AbstractProjectFrame.java 文件源码
项目:geoxygene
阅读 19
收藏 0
点赞 0
评论 0
@Override
public final void addRoadNetworkTxtLayer(final String fileName) {
int lastIndexOfSeparator = fileName.lastIndexOf(File.separatorChar);
String populationName = fileName.substring(lastIndexOfSeparator + 1, fileName.lastIndexOf(".")); //$NON-NLS-1$
logger.info(populationName);
Population<DefaultFeature> population = RoadNetworkTextfileReader.read(fileName, populationName,
this.getDataSet(), true);
logger.info(population.size());
if (population != null) {
this.addFeatureCollection(population, population.getNom());
if (this.getLayers().size() == 1) {
try {
this.getLayerViewPanel().getViewport().zoom(population.envelope());
} catch (NoninvertibleTransformException e1) {
e1.printStackTrace();
}
}
}
}
CreatePolygonMode.java 文件源码
项目:geoxygene
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void leftMouseButtonClicked(final MouseEvent e,
final ProjectFrame frame) {
try {
DirectPosition p = frame.getLayerViewPanel().getViewport()
.toModelDirectPosition(e.getPoint());
if (e.getClickCount() >= 2) {
if (this.getPoints().size() >= 3) {
this.getGeometryToolBar().createPolygon(this.getPoints());
this.getPoints().clear();
}
} else {
this.getPoints().add(p);
}
frame.getLayerViewPanel().superRepaint();
} catch (NoninvertibleTransformException e1) {
e1.printStackTrace();
}
}
CairoGraphics2D.java 文件源码
项目:javify
阅读 23
收藏 0
点赞 0
评论 0
/**
* Set the current transform
*/
public void setTransform(AffineTransform tx)
{
// Transform clip into target space using the old transform.
updateClip(transform);
// Update the native transform.
setTransformImpl(tx);
// Transform the clip back into user space using the inverse new transform.
try
{
updateClip(transform.createInverse());
}
catch (NoninvertibleTransformException ex)
{
// TODO: How can we deal properly with this?
ex.printStackTrace();
}
if (clip != null)
setClip(clip);
}
Viewport.java 文件源码
项目:geoxygene
阅读 23
收藏 0
点赞 0
评论 0
/**
* Zoom to the given coordinates with the given width and height.
*
* @param x
* upper left corner X coordinate
* @param y
* upper left corner Y coordinate
* @param widthOfNewView
* widht of the new view
* @param heightOfNewView
* height of the new view
* @throws NoninvertibleTransformException
* throws an exception when the transformation fails
*/
public final void zoom(final int x, final int y,
final double widthOfNewView, final double heightOfNewView)
throws NoninvertibleTransformException {
LayerViewPanel lvp = this.layerViewPanels.iterator().next();
double zoomFactor = Math.min(lvp.getWidth() / widthOfNewView,
lvp.getHeight() / heightOfNewView);
double realWidthOfNewView = lvp.getWidth() / zoomFactor;
double realHeightOfNewView = lvp.getHeight() / zoomFactor;
IEnvelope zoomEnvelope;
try {
zoomEnvelope = this.toModelEnvelope(x - Viewport.ZERO_POINT_FIVE
* realWidthOfNewView, x + Viewport.ZERO_POINT_FIVE
* realWidthOfNewView, y - Viewport.ZERO_POINT_FIVE
* realHeightOfNewView, y + Viewport.ZERO_POINT_FIVE
* realHeightOfNewView);
} catch (NoninvertibleTransformException ex) {
this.zoomToFullExtent();
return;
}
this.zoom(zoomEnvelope);
}
RenderUtil.java 文件源码
项目:geoxygene
阅读 27
收藏 0
点赞 0
评论 0
/**
* @param geometry
* geometry to fill
* @param viewport
* viewport
* @param graphics
* graphics to draw into
*/
@SuppressWarnings("unchecked")
public static void fill(final IGeometry geometry, final Viewport viewport,
final Graphics2D graphics, double opacity) {
if (geometry.isPolygon()) {
try {
Shape shape = viewport.toShape(geometry);
if (shape != null) {
graphics.fill(shape);
}
} catch (NoninvertibleTransformException e) {
e.printStackTrace();
}
} else {
if (geometry.isMultiSurface()) {
GM_Aggregate<IGeometry> aggregate = (GM_Aggregate<IGeometry>) geometry;
for (IGeometry element : aggregate) {
RenderUtil.fill(element, viewport, graphics, opacity);
}
}
}
}
AttributeValues.java 文件源码
项目:jdk8u_jdk
阅读 22
收藏 0
点赞 0
评论 0
private static AffineTransform extractRotation(Point2D.Double pt,
AffineTransform tx, boolean andTranslation) {
tx.deltaTransform(pt, pt);
AffineTransform rtx = AffineTransform.getRotateInstance(pt.x, pt.y);
try {
AffineTransform rtxi = rtx.createInverse();
double dx = tx.getTranslateX();
double dy = tx.getTranslateY();
tx.preConcatenate(rtxi);
if (andTranslation) {
if (dx != 0 || dy != 0) {
tx.setTransform(tx.getScaleX(), tx.getShearY(),
tx.getShearX(), tx.getScaleY(), 0, 0);
rtx.setTransform(rtx.getScaleX(), rtx.getShearY(),
rtx.getShearX(), rtx.getScaleY(), dx, dy);
}
}
}
catch (NoninvertibleTransformException e) {
return null;
}
return rtx;
}
AffineGeoTransform.java 文件源码
项目:sumo
阅读 27
收藏 0
点赞 0
评论 0
public void setTransformTranslation(int x, int y) {
try {
// go back to initial values
pix2geo.translate(-m_translationX, -m_translationY);
// apply new translation to transform
pix2geo.translate(-x, -y);
// update reverse transform
geo2pix = pix2geo.createInverse();
// keep new tranform values
m_translationX = -x;
m_translationY = -y;
} catch (NoninvertibleTransformException ex) {
logger.error(ex.getMessage(),ex);
}
}