DotA’s Castle Fight Game Mode

from what i’ve read here, Castle Fight’s gamemode need to be entered by player 1 in the first 20 seconds of gametime before round 1 starts.
It has lots of gamemodes, while my favorite is

-rr2 -ntb -nt -nafk -balance -slb -ur -fow -ca -ban -skip

-rr2 = Random races with new races each round with 2 win limit
-ntb = You can’t build Treasure Boxes when this modification has been chosen.
-nt = You don’t have to pay taxes on your income when No Taxes is chosen.
-nafk = Players can’t use the “-afk” command and the AI will also not take control over an afk player after some time.
-balance = Activates auto team balance.
-slb = Units can only move / fly over one lane. -sl picks a random lane while -slt picks the top lane and -slb the bottom lane
-ur = A race can be chosen only once per round (even across the teams).
-fow = There will be Fog of War at the beginning of each round for X seconds. If you just write -fow without a number, you will have indefinite fog of war.
-ca = You are able to block units by building buildings around them in this gamemode. You can use this to build farms like in earlier versions
-ban = Before races get picked/randomed the leader of each team bans X races which cannot be picked/randomed then
-skip = Write this during the first 20 seconds to start round1 immediately (if you have already chosen gamemodes and can’t wait )

Have Fun playing it. ;)

Google+

Anything for A Good Picture

ada yang sampe nungging, jongkok dan segala jenis posisi, cekidot gaaan.

ini posisi nungging

zoom sampe mentok

posisi jongkok

ini buah apa yg dipoto??

models : asung, ir dan gw sendiri.

Google+

I Love the Blue of Sawarna

Sawarna, this place is about 280 km south from jakarta, around 7 hours in a normal traffic to get there. Excellent beaches, Excellent people, Excellent scenery. And believe me, it’s worth the trip.

pantai1

pantai1

pantai1

pantai1

pantai1

pantai1

Google+

Membuat Aplikasi Reporting sederhana dengan JasperReport dan Java Swing

Beberapa hari terakhir ini, gw ditanyain terus tentang caranya connect java swing ke jasper report. Dan konyolnya, gw juga udah lupa caranya. Maklum, kebanyakan copy-paste jadi begini niy. Ya udh supaya inget dan gag lupa-lupa lagi, gw paste disini aja sourcenya.

Gw coba bikin report gembel sederhana dulu, yg ambil data nama dan alamat dari table “contoh” yang ada di database “test”. Pertama-tama kita bikin dulu table nya didatabase,

CREATE TABLE `contoh` (
  `nama` varchar(30) NOT NULL DEFAULT '',
  `alamat` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`nama`)
)

Abis itu kita bikin file jrxml-nya, nanti file jrxml ini akan dicompile on-the-fly oleh compiler jadi .jasper.

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Iseng" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
	<parameter name="nama1" class="java.lang.String"/>
	<queryString>
		<![CDATA[SELECT
     contoh.`nama` AS contoh_nama,
     contoh.`alamat` AS contoh_alamat
FROM
     `contoh` contoh
where contoh.`nama` like $P{nama1}]]>
	</queryString>
	<field name="contoh_nama" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="contoh_alamat" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="56" splitType="Stretch">
			<staticText>
				<reportElement x="0" y="0" width="555" height="46"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font size="24"/>
				</textElement>
				<text><![CDATA[Testing Report]]></text>
			</staticText>
		</band>
	</title>
	<pageHeader>
		<band height="13" splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="34" splitType="Stretch">
			<staticText>
				<reportElement x="0" y="11" width="100" height="20"/>
				<textElement textAlignment="Center" verticalAlignment="Middle"/>
				<text><![CDATA[Nama]]></text>
			</staticText>
			<staticText>
				<reportElement x="132" y="11" width="100" height="20"/>
				<textElement textAlignment="Center" verticalAlignment="Middle"/>
				<text><![CDATA[Alamat]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="27" splitType="Stretch">
			<textField>
				<reportElement x="0" y="0" width="100" height="20"/>
				<textElement textAlignment="Center" verticalAlignment="Middle"/>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{contoh_nama}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="132" y="0" width="100" height="20"/>
				<textElement textAlignment="Center" verticalAlignment="Middle"/>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{contoh_alamat}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="45" splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band height="54" splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band height="42" splitType="Stretch"/>
	</summary>
</jasperReport>

Di situ gw bikin satu report yang akan mencari data di table contoh berdasarkan query nama. Perhatikan line 10, itu adalah variabel yang akan gw gunakan untuk menjadi variabel query report.

Setelah jadi reportnya, sekarang gw lanjut bikin tampilannya. Gw pakek java Swing buat bikin UI. Jadi harap maklum klo rada kacrut sederhana.

package com.edw.frame;

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;

import org.apache.log4j.Logger;

/**
 *
 * @author edw
 */
public class FrameMain extends JFrame implements ActionListener {

    private Logger logger = Logger.getLogger(FrameMain.class);
    private JTextField txtNama = new JTextField(20);
    private JButton cmdPrint = new JButton("cetak");

    public FrameMain() {
        init();
    }

    private void init() {
        Container conn = getContentPane();
        conn.setLayout(new FlowLayout());
        conn.add(new JLabel("Iseng"));
        conn.add(txtNama);
        conn.add(cmdPrint);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        cmdPrint.addActionListener(this);
        pack();
    }

    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == cmdPrint) {
            try {
                // parameter
                String parameterNama = txtNama.getText();

                //load report location
                FileInputStream fis = new FileInputStream("src\\com\\edw\\rpt\\Iseng.jrxml");
                BufferedInputStream bufferedInputStream = new BufferedInputStream(fis);

                //set parameters
                Map<String, String> map = new HashMap<String, String>();
                map.put("nama1", parameterNama);

                Class.forName("com.mysql.jdbc.Driver");
                Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "xxxx");


                //compile report
                JasperReport jasperReport = (JasperReport) JasperCompileManager.compileReport(bufferedInputStream);
                JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, map, connection);

                //close connection
                connection.close();

                //view report to UI
                JasperViewer.viewReport(jasperPrint, false);

            } catch (Exception ex) {
                logger.error(ex.getMessage(), ex);
            }

        }
    }

    public static void main(String[] args) {
        new FrameMain().setVisible(true);
    }
}

Coba cek di line 64, itu adalah parameter yang akan dikirim ke report, pastikan nama variabelnya sama dengan nama variabel yang ada di jasper report ( file jrxml ). Sedangkan line 67 adalah Koneksi database gw, silahkan di modifikasi sesuai keinginan.

Nanti klo udh dijalanin, jadinya kayak gini
Form UI

terus klo misalkan text field nya diisi dengan “edwin” dan kemudian menekan tombol “cetak”, maka akan muncul form report dengan data “edwin” yang kita cari.
report jasper

berikut adalah struktur project gw serta library (jar) apa aja yg gw pake.
jasper report jar project structure
harap diingat, lokasi jar yg gw pake ada di dalam folder instalasi Jasper Report, silahkan di search aja.

nah ini adalah isi database gw, coba di cek output dari jasper dan isi databasenya, sinkron apa engga.
isi db

Sekian dan terima kasih.

nb. Oh iya, hasil preview dari jasper report juga bisa di save as ke berbagai macam format, tinggal di save aja.
export jasper into another format

Google+

When Edward meet Blade

PWND..!!

When Edward meet Blade

Google+