Skip to content

Instantly share code, notes, and snippets.

View mojaie's full-sized avatar
🐢
Sorry for late responses

Seiji Matsuoka mojaie

🐢
Sorry for late responses
View GitHub Profile
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
// 描画キャンパスの設定
Rectangle drawArea = new Rectangle(20, 20, 360, 360);
BufferedImage img = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = img.createGraphics();
g2.fillRect(0, 0, 400, 400);
// ジェネレーターの設定
List<IGenerator> generators = new ArrayList<IGenerator>();
generators.add(new BasicBondGenerator());
generators.add(new ExtendedAtomGenerator());
// レンダリング
// 水素原子の削除
molecule = (IMolecule) AtomContainerManipulator.removeHydrogens((IAtomContainer) molecule);
// 末端、ヘテロ原子上の水素のみ表示
CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(molecule.getBuilder());
for (IAtom atom : molecule.atoms()) {
try {
IAtomType type = matcher.findMatchingAtomType(molecule, atom);
atom.setImplicitHydrogenCount(
type.getFormalNeighbourCount() - molecule.getConnectedAtomsCount(atom));
} catch (CDKException e) {
// 3D→2D変換
tructureDiagramGenerator sdg = new StructureDiagramGenerator();
sdg.setMolecule(molecule);
try {
sdg.generateCoordinates();
} catch (CDKException e) {
e.printStackTrace();
}
molecule = sdg.getMolecule();
Reader reader = null;
try {
reader = new FileReader(new File("./temp/test/zinc_3929508.sdf"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
MDLV2000Reader mdl = new MDLV2000Reader(reader);
IMolecule molecule = null;
try {
molecule = (IMolecule)mdl.read(new Molecule());
@mojaie
mojaie / gist:2729985
Created May 19, 2012 07:56
CakePHP:test002_2
<?php
class UsersController extends AppController {
public function beforeFilter() {
$this->Auth->allowedActions = array('login');
parent::beforeFilter();
}
public function isAuthorized() {
@mojaie
mojaie / gist:2729847
Created May 19, 2012 07:18
CakePHP:test002_1
<?php
class TestsController extends AppController {
public $layout = null;
public function beforeFilter(){
//openaccessには誰でもアクセスできる
$this->Auth->allowedActions = array('openaccess');
//親クラス(AppController)読み込み
parent::beforeFilter();
@mojaie
mojaie / gist:2729768
Created May 19, 2012 06:48
CakePHP:test002_0
<?php
class AppController extends Controller {
public $components = array('Auth');
public function beforeFilter(){
$this->Auth->authorize = 'Controller';
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
if ($this->Auth->loggedIn()) {
@mojaie
mojaie / gist:2729432
Created May 19, 2012 05:44
CakePHP:test001_1
<?php
class TestsController extends AppController {
public function index() {
$this->helpers = array('Html');
debug($this->helpers);
}
}
@mojaie
mojaie / gist:2729398
Created May 19, 2012 05:34
CakePHP:test001_0
<?php
class TestsController extends AppController {
public function index() {
debug($this->components);
debug($this->helpers);
debug($this->actsAs);
}
}