Tag Archive for flip

Flipping objects with a Matrix

function flipHorizontal(dsp:DisplayObject):void {
var matrix:Matrix = dsp.transform.matrix;
matrix.a = -1;
matrix.tx = dsp.width + dsp.x;
dsp.transform.matrix = matrix;
}

function flipVertical(dsp:DisplayObject):void {
var matrix:Matrix = dsp.transform.matrix;
matrix.d = -1;
matrix.ty = dsp.height + dsp.y;
dsp.transform.matrix = matrix;
}

source

Flip Myspace Tables

<style type="text/css">
table {
direction: rtl;
}
table table table {
direction: ltr;
}
</style>

source

flipping a view on the iphone sdk

- (void) flipView {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:kTransitionDuration];

[UIView setAnimationTransition:([mainView superview] ?
UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight)
forView:self.view cache:YES];

if ([flipView superview])
{
[flipView removeFromSuperview];
[self.view addSubview:mainView];
}
else
{
[mainView removeFromSuperview];
[self.view addSubview:flipView];
}

[UIView commitAnimations];
}

source

Flip your text with charsets

function flip() {
var result = flipString(document.f.original.value.toLowerCase());
document.f.flipped.value = result;
}

function flipString(aString) {
var last = aString.length - 1;
//Thanks to Brook Monroe for the
//suggestion to use Array.join
var result = new Array(aString.length)
for (var i = last; i >= 0; --i) {
var c = aString.charAt(i)
var r = flipTable[c]
result[last - i] = r != undefined ? r : c
}
return result.join('')
}

var flipTable = {
a : 'u0250',
b : 'q',
c : 'u0254', //open o -- from pne
d : 'p',
e : 'u01DD',
f : 'u025F', //from pne
g : 'u0183',
h : 'u0265',
i : 'u0131', //from pne
j : 'u027E',
k : 'u029E',
//l : 'u0283',
m : 'u026F',
n : 'u',
r : 'u0279',
t : 'u0287',
v : 'u028C',
w : 'u028D',
y : 'u028E',
'.' : 'u02D9',
'[' : ']',
'(' : ')',
'{' : '}',
'?' : 'u00BF', //from pne
'!' : 'u00A1',
"'" : ',',
'<' : '>',
'_' : 'u203E',
';' : 'u061B',
'u203F' : 'u2040',
'u2045' : 'u2046',
'u2234' : 'u2235'
}

for (i in flipTable) {
flipTable[flipTable[i]] = i
}

source

J2ME – HelloWorld

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class HelloJ2ME_a1 extends MIDlet
{
private Display mDisplay;
private Form mForm;

protected void startApp() throws MIDletStateChangeException
{
if(mForm == null)
{
// Creo il Form dove inserire il messaggio (questo puo' essere pensato come ad un JFrame)
mForm = new Form("Hello J2ME !!!");

// Ottengo un Display per la MIDlet
mDisplay = Display.getDisplay(this);
}

// Imposto il Form corrente nel Display
mDisplay.setCurrent(mForm);
}

protected void pauseApp()
{

}

protected void destroyApp(boolean arg0) throws MIDletStateChangeException
{
// Notifico alla JVM della morte della MIDlet (viene chiamato il Garbage Collector)
this.notifyDestroyed();
}
}

source

J2ME – System Properties

package System;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class SystemProperties extends MIDlet implements CommandListener
{
private Command esci;

private Display display;

private Form form;

protected void startApp() throws MIDletStateChangeException
{
display = Display.getDisplay(this);

form = new Form("System Propiertis");
form.setCommandListener(this);

esci = new Command("Esci", Command.EXIT, 0);
form.addCommand(esci);

Runtime rt = Runtime.getRuntime();
rt.gc(); // Garbage Collection

form.append("Free Memory: " + rt.freeMemory() + "
");
form.append("Total Memory: " + rt.totalMemory() + "
");
form.append(showProp("microedition.configuration"));
form.append(showProp("microedition.platform"));
form.append(showProp("microedition.locale"));
form.append(showProp("microedition.encoding"));
form.append(showProp("microedition.encodingClass"));
form.append(showProp("microedition.http_proxy"));

display.setCurrent(form);
}

protected void pauseApp()
{

}

protected void destroyApp(boolean unconditional) throws MIDletStateChangeException
{
notifyDestroyed();
}

public String showProp(String str)
{
String value = System.getProperty(str);
StringBuffer stringbuffer = new StringBuffer(50);

stringbuffer.setLength(0);
stringbuffer.append(str);
stringbuffer.append(" = ");

if(value == null)
stringbuffer.append("<undefined>");
else
{
stringbuffer.append(""");
stringbuffer.append(value);
stringbuffer.append(""");
}

stringbuffer.append("
");

return stringbuffer.toString();
}

public void commandAction(Command c, Displayable d)
{
if(c == esci)
{
try
{
destroyApp(true);
}
catch(MIDletStateChangeException e)
{
showException(e);
}
}
}

public void showException(Exception e)
{
Alert alert = new Alert("Errore !!!");
alert.setString(e.getMessage());
alert.setType(AlertType.ERROR);
alert.setTimeout(Alert.FOREVER);

display.setCurrent(alert);
}
}

source

Java – imgFromJar

try
{
icon = ImageIO.read(getClass().getResourceAsStream("imgs/icon.png")); // La preleva dal file jar
setIconImage(icon);
}
catch(IOException e)
{
e.printStackTrace();
}

source

Java – ZoomIN Image

public BufferedImage zoomIn(BufferedImage bi, int scale)
{
int width = scale * bi.getWidth();
int height = scale * bi.getHeight();

BufferedImage biScale = new BufferedImage(width, height, bi.getType());

// Cicla dando un valore medio al pixel corrispondente
for(int i=0; i<width; i++)
for(int j=0; j<height; j++)
biScale.setRGB(i, j, bi.getRGB(i/scale, j/scale));

return biScale;
}

source

Java – ZoomOUT image

public BufferedImage zoomOut(BufferedImage bi, int scale)
{
int width = bi.getWidth() / scale;
int height = bi.getHeight() / scale;

BufferedImage biScale = new BufferedImage(width, height, bi.getType());

for(int i=0; i<width; i++)
for(int j=0; j<height; j++)
biScale.setRGB(i, j, bi.getRGB(i*scale, j*scale));

return biScale;
}

source

Java – FlipH / FlipW

public BufferedImage flipH(BufferedImage bi)
{
int width = bi.getWidth();
int height = bi.getHeight();

BufferedImage biFlip = new BufferedImage(width, height, bi.getType());

for(int i=0; i<width; i++)
for(int j=0; j<height; j++)
biFlip.setRGB((width-1)-i, j, bi.getRGB(i, j));

return biFlip;
}


public BufferedImage flipW(BufferedImage bi)
{
int width = bi.getWidth();
int height = bi.getHeight();

BufferedImage biFlip = new BufferedImage(width, height, bi.getType());

for(int i=0; i<width; i++)
for(int j=0; j<height; j++)
biFlip.setRGB(i, (height-1)-j, bi.getRGB(i, j));

return biFlip;
}

source